kiralmarch
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Adding “Comments” to non-WordPress PagesOkay, it was messy but I got it working. All the individual photo pages on my site now take comments. Check it out: https://kiramarch.com/photo.php?id=0208%20outside.jpg&tag=favorites
(Yes, I know flickr does all this and more, but I wanted a more sophisticated tagging system than flickr supports, and I needed a project to learn php on.)
The only thing I haven’t gotten working is the Ajax plugin (it’s still doing fine on my WP pages, though).
Here’s what I had to do:
Add to my DB structure
– new table with my page ID and an autonumber
– new ID field in my main data table. Uses a negative number corresponding to the autonumber in the translation table…this way it will never bump into WP posts and mix up comments.
– auto-fill that new negative ID number each time I add a pagechange my page template to incorporate the comments
– added calls to get_post (fills in the data wp needs to write the comments) and comment_template (displays and solicits the comments)
– if i want to get ajax plugin turned on, must add the includes in the header by hand (I’m not using the wp header)Then in functions.php:
– changed get_post to set global $id, since it has to be shared among more functions now
– get_post handles the negative number fine, it turns outChanges to comment-functions.php
– In comments_template function, added access to global $id and conditional so that it will execute with neg number
– Also added a couple new cases so that it doesn’t look up negative IDs in the wp_posts table, since it won’t find anything.
– In wp_insert_comment…put in one new condition that assumes comments are open on all photo pages.Then wp-comments-post.php, which is what the add a comment form calls
– Skipped the status check if the ID is negativeAnd finally, in comments.php:
– Construct and pass optional redirect location because it won’t know what to reload on its own
– Pointed a redirect to an anchor to make the reloading less annoying (until/unless I get the ajax plugin working)
– Changed the comment section heading to static because it was looking up info about the posts. Static doesnt bother me, but I could have skipped it just for the hacked pages if I cared.All done!
Forum: Fixing WordPress
In reply to: Adding “Comments” to non-WordPress PagesThat js-kit.com thing would be great, except that I can’t get it to work with my dynamically generated URLs. Posted on the thread there, and no one has been able to help. ??
Vkaryl, thanks for posting your soln. I’m not sure I completely understand what you did, but I don’t think I want to do exactly the same thing. I want to put add/view comments on *many* non-wp pages on my site — a few thousand photo pages. I think it’s going to require hacking the post/comment ID system.
It looks possible, but I’ll probably break a bunch of stuff along the way. :-/
One problem: Without an associated ID in the wp_posts table, comments won’t be recognized as open so people won’t be able to make them. The best workaround seems to be modifying the check for comment status in wp-comments-post.php so I can tell it to treat comments as open. (I think that’s better than adding dummy posts to the wp_posts table, and I don’t mind not being able to close comments on a post easily.)
Another (smaller) problem: In reading comments out of the DB, I’ll have to come up with an ID system for them that won’t interfere with the association of regular comments with wp_posts. Since it’s a numeric field, the only option I see is to start at the max value for the field and count down, betting that it will never meet my post count. (A good bet.) I can automatically assign that ID when I create each non-WP page.
Final problem: I’ll have to modify the comment_template function, since it looks up the post ID…I think I’ll have to feed it the post ID as a parameter and only let it look up if the parameter is null.
If anyone’s found a different way or has other thoughts, let me know!! Otherwise, I’ll tackle it this weekend, and let you know how it works out. Good thing it’s going to rain…
Forum: Fixing WordPress
In reply to: Adding “Comments” to non-WordPress PagesYes, I am trying to do exactly the same thing! Everything else on my site runs off a mySQL DB, too, so I was planning to hack the comment function to allow it to associate comments with another key.
Haven’t had time yet to dig through and figure out exactly how the comment functions work, though, so I’m curious to see/hear how someone else has done it. Thanks in advance!