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.