Jump to content

YouTube style comment replies


helpmeplease2

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

  |

  |

  |___________________________________________

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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*

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.