helpmeplease2 Posted February 7, 2008 Share Posted February 7, 2008 I already have an ajax commenting system, but I want to add the feature to allow users to reply to comments. Is there someone who knows how to do this? I am a beginner at PHP so I'm pretty sure I can't do this myself. If you can add the ability to reply to comments like on YouTube then you can have a link on my website for free. (site: www.gameanyone.com) Email me if you want to help you: derek_dude12@yahoo.com Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/ Share on other sites More sharing options...
frijole Posted February 7, 2008 Share Posted February 7, 2008 what you have to do is make a new column in your comment table that contains the id of the parent comment. So, if it was a comment that was new the parent id would be null. but, if the comment was a reply then the parent id would be the id of the comment that was being replied to. this way you can also have replies to replies. Also, this question might be better off in a different section. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-460564 Share on other sites More sharing options...
helpmeplease2 Posted February 7, 2008 Author Share Posted February 7, 2008 I get that part. But I am not sure how I would say to echo replies in the same query as the normal comments to get everything in the right place. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461098 Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 If you want Youtube style then lets say this is your comment table: ____________________________________________ | Comment Title: this is the comment title | message: this is the comment | | |___________________________________________ |Reply number 1: |sdfjdkfjskdfjskdjfkjdkfjfd |_________________________________________- You count all the number of quotes or replies to comments belong to that comment id, if its more than 0 then echo the tr or td or whatever, else it should be ____________________________________________ | Comment Title: this is the comment title | message: this is the comment | | |___________________________________________ Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461101 Share on other sites More sharing options...
PHP Monkeh Posted February 7, 2008 Share Posted February 7, 2008 One thing I'm quite interested in is how do you handle unlimited nesting? As in, what happens if someone replied to a comment, which was a reply to another comment, which again was a reply to another comment etc. Is there a way of finding out the nesting structure? And to be able to handle an infinite number this way - much like how a directory tree works. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461109 Share on other sites More sharing options...
Wolphie Posted February 7, 2008 Share Posted February 7, 2008 Only have a reply link on the parent comment Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461149 Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 Have a Table under each Comment that is posted, only show that table with repeating regions in it each aligned to the right a bit if there is a reply to the comment. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461173 Share on other sites More sharing options...
roopurt18 Posted February 7, 2008 Share Posted February 7, 2008 PHP Monkey One thing I'm quite interested in is how do you handle unlimited nesting? As in, what happens if someone replied to a comment, which was a reply to another comment, which again was a reply to another comment etc. Is there a way of finding out the nesting structure? And to be able to handle an infinite number this way http://dev.mysql.com/tech-resources/articles/hierarchical-data.html Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461301 Share on other sites More sharing options...
helpmeplease2 Posted February 7, 2008 Author Share Posted February 7, 2008 I am so confused. And if they are replies will it still limit them on a certain amount per page? This is all way over my head. Is someone brave enough to do it in exchange for a link? Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461340 Share on other sites More sharing options...
helpmeplease2 Posted February 8, 2008 Author Share Posted February 8, 2008 I think I might be able to program basic replies.... should replies should be in their own table? Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461374 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 I think I might be able to program basic replies.... should replies should be in their own table? In there own table under each comment. Show the table if there are more than 1 replies for the comment... ill post and example later. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461378 Share on other sites More sharing options...
helpmeplease2 Posted February 8, 2008 Author Share Posted February 8, 2008 I made it so I can show replies correctly. Now how do I make it to INSERT replies? I want to make it so it shows a new textarea box when a user clicks reply. I have done this, but I am having problems inserting the comment id that it is a reply to. http://www.gameanyone.com/?p=video&game=Crysis&id=9541 There is alot of code, too much to post here. And if you click reply you can see that the new textarea box would only appear below the first comment, not under the comment that the reply is for. *cry* If I emailed one of you all the code would you make it work? *cry* Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461456 Share on other sites More sharing options...
roopurt18 Posted February 8, 2008 Share Posted February 8, 2008 Getting the comment box to display under the clicked link is a Javascript problem. The short answer is if you use the Javascript event model correctly, the event handler will receive a reference to the node that caused the event. From there you can very easily create and insert a textarea with the DOM. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461519 Share on other sites More sharing options...
frijole Posted February 8, 2008 Share Posted February 8, 2008 roopurt, where can I learn more about what you just said up here ^. I would like to learn more about java, or some i guess i should say. That seems like an interesting/useful project. I am trying to figure out a discussion page and that ^ is what i have been confused about. by the way, i am talking about making the text area appear when you hit reply. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461902 Share on other sites More sharing options...
PHP Monkeh Posted February 8, 2008 Share Posted February 8, 2008 Just so you know it's JavaScript you're wanting to look for, not Java. You'll get totally the wrong tutorials if you look for Java. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-461942 Share on other sites More sharing options...
roopurt18 Posted February 8, 2008 Share Posted February 8, 2008 You should find plenty of tutorials, hints, and / or suggestions from this Google search: http://www.google.com/search?q=Javascript+event+model Specifically, you want to look for tutorials that show you how to use JavaScript code like: addEventListener(); // netscape, opera, firefox attachEvent(); // internet explorer Any tutorials that show you how to do the following should be avoided: <a href="http://www.google.com" onclick="some_javascript();">Click here</a> The short version is HTML, CSS, JavaScript, etc. should all be separate. You should not be placing JavaScript in your markup, least of all for events. The event models exposed by IE and mozilla browsers make event handlers within the markup unnecessary; it is a slight pain to work with two different event models, but the payoff is well worth it. I even took the time to create a JavaScript Events interface that wraps up both models into a single interface, thus making event handling a breeze for me. As far as the DOM is concerned, you want to learn how to use methods like document.getElementById(), document.createElement(), etc. W3Schools has some good DOM tutorials (and likely some good events tutorials as well). If you want it all wrapped up in a book, I recommend: http://www.oreilly.com/catalog/jscript3/ Lastly, I have an article dealing with attaching events to an iframe which might help you as well: http://www.rbredlau.com/drupal/node/7 Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-462129 Share on other sites More sharing options...
helpmeplease2 Posted February 11, 2008 Author Share Posted February 11, 2008 I am still stuck trying to get this to work. $50 to anyone who will make it work for me. This is what I have so far so there shouldn't be too much work: http://www.gameanyone.com/?p=video&id=9541 Email me at derek_dude12@yahoo.com if you're interested. Quote Link to comment https://forums.phpfreaks.com/topic/89845-youtube-style-comment-replies/#findComment-464420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.