SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    threaded forum design

    Hmmm. Perhaps I should have put this in the databases forum, but now I don't see how to delete it...

    I want a php-based forum I can install as the contents of a DIV, rather than as a independent page (no HTML, HEAD and BODY) There are a few simple ones out there, but none that support a "hierarchical, threaded message" view, which I also want.

    So I'm thinking about writing my own bare bones but threaded forum.
    Perhaps this could be done with three tables: user, forum and post,
    where the post.parent_post_id would be zero for thread heads.
    post.indent_count would be one more than the indent_count for the parent_post_id.

    Ordering the display, so all the first level children of post_id = X would appear both indented and below the parent subject line could be ddone with an enormously expensive recursive procedure. But I doubt that's a good idea.

    There must be a way to use a table similar to what is below, combined with "order by" and "group by" ....perhaps using a cursor or two, to pull out the posts in the requisite order, and where post.indent_count kludges the hierarchical display
    ...or am I barking up an impossible tree?

    CREATE TABLE post (
    post_id int(4) NOT NULL auto_increment,
    forum_id int(4) NOT NULL references forum(fid),
    user_id int(4) NOT NULL references thread_user(uid),
    parent_post_id int(4) NOT NULL default 0 references comment(cid),
    indent_count int(4) NOT NULL default 0,
    title varchar(96) NOT NULL,
    body text,
    PRIMARY KEY (post_id)
    ) ENGINE=MyISAM

  2. #2
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can i ask why you are trying to make your own forum ? The only reason i ask is that forums can become very complicated very quickly and there are a lot of security considerations you need to keep in mind; this is why most people use an existing solution such as vbulletin etc.

    In regards to your post about threaded design have a look at this http://www.technabled.com/2009/06/ho...ts-in-php.html it's about multi levelled comments but may give you some ideas. Basically one way you go do it is return all posts with no parent as these are your threads, and then as you mentioned recursively get the replies to these threads.

    e.g.:

    Code:
    while($row = mysql_fetch_assoc($r)) {  
       getChildren($row);  
    }
    getChildren being the method to get the posts in that thread.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It will take some time to evaluate the link you posted (thank you for that).
    And it's almost new years, and I'm off for two weeks of fishing in Hawaii day after tomorrow.

    Why would I write my own forum? I did once. I ran a boat building forum at montana riverboats for six or seven years, running on home-rolled code. I accumulated close to 10,000 posts and I did (it was a constant battle) keep the creeps at bay. What I started out with was a files-based but threaded forum. I finally threw in the towel and migrated to phorum. The export-to-forum script was a three or four day job. But it worked. I used forum because....well. Databases are better. With my files based hack no one could go back and edit their work. Everybody did like the threaded format, where you could see that user Sam was responding to exactly which post made by Whatshisname.

    I want to abandon phorum now because its *.tpl templating system is so horribly coupled to separately written PHP coding it's too hard to modify. And worse yet it is impossible to use it as the contents of a DIV inside my own (home rolled CMS).

    I want a bare-bones threaded forum, that I can use as a plugin DIV contents. I can handle captcha, IP banning and username banning. And even a little keyword banning.

    I'm leaning towards the aforementioned XML blob as way to maintain hierarchy, with everything else relational. I do have 5-years experience with XML databases like Exist and SleepyCat. So XPath is almost second nature to me now. I looked (again) at Celko's nested set model. Maybe. But it isn't intuitive coding. I'd have to wrap it all in a home-rolled API if I wanted transparent coding. This will be a fun project. No matter what. I did do it all once already. So I have confidence I can do it again.


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
  •