[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] different strategies



Hi,

I've got some ideas you might want to think about. My own forum works as
follows:

I have one counter file. This file contains a number like 22.35. The first
number is the thread-ID (number of the next top-level posting). The second
number is the message-ID (number of the next posting in general). I'll
explain this later.

Then I have a data file, which contains one forum posting per line. Each
line is separated into fields (thread-ID, posting-ID, level, date, name,
email, subject, text etc.).

Now, my forum script does all the work. Calling it with the name of the
forum ONLY, it creates a file name from it (e.g. forum.cgi?name=test would
internally access the two files test.cnt and test.for) and reads all the
information. Then it displays the structure following this algorithm
(pseudo-code):

----------
level = -1
ULCount = 0;
foreach forumitem do
{
  while (forumitem.level > level)
  { print "<UL>"; level++; ULCount++; }

  while (forumitem.level < level)
  { print "</UL>"; level--; ULCount--; }

  print "<LI><A HREF=...>forumitem.subject</A>"; # and other information
}

while (ULCount > 0) { print "</UL>"; ULCount--; }
----------


This way I create the structure from the contents file. Each item in this
structure is a link, which again calls the forum script, but in addition to
the name of the forum I pass a "read" parameter containing the message-id of
the message to be displayed. When the script gets the read parameter also,
it displays a page where you can read the posting and answer using a reply
form. It just wraps all the information from the contents file into nice
HTML code.

Posting a message in the structure output page creates a new entry at the
top of the contents file with the next thead-id, next message-id (both are
also written to the counter file) and level 0. This way, latest postings are
always first in the structure.

Posting a message in the read output page creates a new entry in the
contents file right after the item you are replying to. Same thread-id, next
message-id, level of the item+1. This way, latest answers are always first.

Having the thread-id allows you to display a little mini-structure on the
read output page to navigate through the thread. As new threads always have
level 0, you can just use the same algorithm as above.

This may sound more complicated than it actually is. Actually, when you
think about it, it is quite simple compared to the functionality it
provides. You can then write an administrator-page for yourself, where you
can remove postings or entire threads by just removing ONE line from the
contents file!

If you still need code, I can send you the most important code snippets to
your private email address. Please let me know...

Thorsten

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org