Threaded Forums Made Easy
Not too much about Perl, but just wanted to say that sometimes I have a lovely feeling of accomplishment after struggling to find a good approach. After considering my options about forums, I decided to continue on my own. With the proper tool selection, they're incredibly easy. Below is sample output of my alpha code.
I can pull all replies to a forum post, properly sorted, with a single SQL statement. Each post is simply formatted with this:
[% WHILE ( post = replies.next ) -%] [% level = post.levels; IF level > 6; level = 6; END -%] <li class="comment level[% level %]"> <div class="comment-date">[% post.created %]</div> <div class="comment-title"><a href="[% c.uri_for('/post', post.id) %]">[% post.title | html %]</a></div> <div class="comment-author">by [% post.character.name | html %]</div> <div class="comment-reply">[<a href="[% c.uri_for('/post', post.id, 'reply') %]">reply</a>]</div> <div class="comment-body">[% post.body | html %]</div> </li> [% END %]
The output is ugly and the Template Toolkit code does need need some serious cleaning up (URLs are bad and I shouldn't hard-code the post depth), but it's so much easier than I thought.
After I have a few more things sorted out, I'll post some code snippets on how I made this work (mostly through a clever stored procedure in PostgreSQL).