SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two problems making threaded message board

    Since it's 1am I'm not going to make much sense, but thought I'd throw this out now in th ehope of an answer while I sleep.

    I'm making a threaded message board. My data will be stored using a modified pre-order tree traversal in a MySQL database.

    Problem one: sort order

    I want to sort all messages by last-posted date of a child message. So if you're looking just at top-level messages, they're sorted by last posted date like PHPBB is. If you look at second-level messages, they're sorted by last posted date [i]within[/b] their threads. Any ideas how to do this? (I don't want to use a recursive function to get the posts.)

    Problem two: expand and collapse threads

    I'd like each message that has children to have a little expand/collapse button next to it, like Windows Explorer does. By default, all threads are collapsed. If you hit an expand button, it expands the message you click on and all messages below it. If you hit a collapse button, it collapses the message you click on (so you can't see any messages below it).

    Any ideas how to do that, again without adding extra queries?



    My main point is this: I don't want to treat the top level threads/messages as special cases. And every example script I've looked at either does treat them as special (and as such you can't look at a sub-tree as if it's a tree in its own right), or doesn't support the expand/collapse feature I'd like to do.



    Amorya
    KickRSS - free web-based RSS aggregator.

  2. #2
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the next version of phpBB is using the modified pre-order tree traversal method. You should be able to get it at sourceforge and check it out?

    Matt

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mwmitchell
    I think the next version of phpBB is using the modified pre-order tree traversal method. You should be able to get it at sourceforge and check it out?

    Matt
    I think it does that for the sub-forums but not for threads (as far as I know it's still flat and not fully threaded)...

    will look though. Thanks.

    Amorya
    KickRSS - free web-based RSS aggregator.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    São Paulo, Brasil
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For your first problem, vBulletin uses a solution that breaks normalization: they put the last reply timestamp and the last reply author in the thread row instead of finding the last post on that thread. You have a clear performance gain but a more complex logic when adding replies.

    About the second part I didn't catch it ... you want to fetch *all* posts during the thread list?
    Ricardo "Solo" Hermida Ruiz
    solo (a) hardmob.com.br
    twlimcsb cassmmvi

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Hermida
    About the second part I didn't catch it ... you want to fetch *all* posts during the thread list?
    Yes...

    I'm trying to make a threaded discussion board like Usenet, not a flat one like this board is. So the messages are displayed individually, indented to show which one is in reply to which other.

    My problem is that I'd like to have an expand/collapse function on each message. This site has an example... although on mine I don't want to do the expand/collapse through Javascript (it can be done by reloading the page and the PHP sorts out which is displayed), and I want the collapse buttons to be displayed for every message with any children.


    BTW, I'm using just one table to store all these messages: it has fields:

    ID, Subject, Body, Left value, Right value

    I don't have a separate table for threads or anything.



    Amorya
    KickRSS - free web-based RSS aggregator.

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    São Paulo, Brasil
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, i don't know this pre-order tree traversal well enough to know if there's a method for selecting the last element of a tree.


    About the expand buttons, you coult store in a session array the expanded threads and display them on the next load.

    There's another interesting aproach to this expanding threads:

    http://www.killerwolf.com.br/blog/ (ok, it's in portuguese). Click on 'Comentários' bellow the time in the first post. There's a hidden frame that fetches the comments on that post and populates the <div> content with the comments without reloading the entire page.
    Ricardo "Solo" Hermida Ruiz
    solo (a) hardmob.com.br
    twlimcsb cassmmvi


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •