Jump to content

Hierarchy Comments


ciel

Recommended Posts

Hello all

I'm working on a comment script and it works fine but I wanna implement a feature which is hierarchy comments.

I understand that we need to connect a comment/reply with its topic via parent_id and so on for connecting a reply with a reply to it.

my questions are how can we control that when we do the insertion into the replies table? how will the connection via parent_id be made? and how to choose between post a reply to a topic or to another reply?

 

Thanks.

Link to comment
Share on other sites

^ Pretty much that. All you need to do is pass in the parentID and assign that.

 

Consider:

 

ID: 1

comment: "First Comment"

parentID: NULL

 

ID: 2 

comment: "Second Comment"

parentID: 1

 

ID: 3

comment: "Third Comment"

parentID: 2

 

 

By simply specifying the parentID when doing the reply, you can then get a recursive list of all the comments so that you end up with something like:

Comments Array
(
  [0] = Array
          (
               ID: 1, 
               comment: "First comment", 
               parentID: NULL, 
               replies: Array
                            (
                                    [0] = Array 
                                            (
                                                      ID: 2,
                                                      comment: "Second Comment"
                                                      parentID: 1
                                                      replies = etc......
                                            )
                            )
          )
)
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.