James (unknownj) wrote in s2dev,
James
unknownj
s2dev

More out of curiosity than anything else (too much time and enthusiasm), I was wondering how easy it would be to build a style that implemented flat commenting, rather than threaded.. Ideally, it would be set by an argument in the page URL, so that people could turn it on temporarily with a link..

So I figured that it shouldn't be too difficult to hijack the print comment function, and iterate through all comments (and children of comments), adding all the comments on the entry into an array of comment objects. Forget for a second that some of them might only be partial comments, that's something I haven't figured out a way around yet..

To make the display a bit more user friendly, I was thinking of building a hash or two at the same time that links the poster and talkid of each comment to all the children, so that I can use a comment's talkid to look up the talkid of its parent, and who it was by. The idea then being that a comment can say "Reply to user5 (link to relevant comment)".

But this is where it starts to fall down..

What I'd then be looking to do is sort the array based on the talkid of each comment (ascending). i.e., break the threaded model, and access the comment array in the order in which the comments were written to the database.

Now I think I can probably do that by iterating through the comment array, picking out the lowest talkid, printing it, adding it to another array of "done" comments, and then repeat, excluding those "done" comments every time.. But that seems like a really long-winded way of going about it.

I was just wondering if anybody had any insight into the best way to do this, or any obvious reasons why the whole thing would just break on attempting it. Like I said, it's more out of curiosity than anything else, I just want to see if I can do it (and do it in a well-performing manner).

So.. any ideas? :o)
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 2 comments