vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   hierarchial system/category and forums sytem (https://vborg.vbsupport.ru/showthread.php?t=70380)

AN-net 10-09-2004 05:19 PM

hierarchial system/category and forums sytem
 
hey well ive been trying to get something like vb's category and forum system to work but i cant:( can someone explain to me how to accomplish something like a category and then things under it. i have looked at vb's code for forming the forum list and i see its all done in one query, so i was wondering how does it determine what is a category, what is a forum, and how to place them.... can someone please help:)

peterska2 10-09-2004 06:24 PM

In the forum editor it asks if posts can be made in the forum. It states that it will be treated as a category if no. Set it to no and save it. This will then display as a category.

Then when creating forums, set the parent forum to be the one that you have set to be your category.

AN-net 10-09-2004 06:28 PM

im talking about how the actual functions in /includes/functions_forumlist.php detect/know if its a category and how to group them

Velocd 10-09-2004 06:33 PM

Take a look at the vBulletin table schema for `forum`, and you will notice these columns:

childlist, parentid, parentlist, and forumid.

A hierarchical tree structure of categories composed of subcategories is possible using only the parentid & forumid, as I've done it for a project at my job (this requires a deviously complex recursive function--but only one query), but vBulletin takes an alternative route using supplemental data (parentlist and childlist), which contain the forumids of the parents and children of the current forum).

You can write SQL queries to grab threads and forums from the current forum and all its children easily using childlist. You can go upward, grabbing parent forum data, using the parentlist.

As for categories, that is forums that cannot be posted in (except for their children forums), they are denoted by a parentid of -1.

It's awkard explaining, but it's not very hard to do. The more difficult part that vBulletin places itself at is updating the parentlist and childlist everytime you change a forum into a parent or under another forum.

Dean C 10-09-2004 06:39 PM

There are loads of algorithms and methods to generating a hiearachical category tree. The most popular is the method VelocD described above. If you're interested you may want to check out this article which outlines another (pretty useful) method too:

http://www.sitepoint.com/article/hie...-data-database

Velocd 10-09-2004 07:00 PM

I posed this question on SitePoint back in August when looking for the basic algorithm:
http://www.sitepoint.com/forums/showthread.php?t=186114

The solution I ended using was heavy modifcation of stereofrog's (post#6), which uses only one query and only relies on the parent ID.

AN-net 10-09-2004 07:05 PM

well i was analyzing that article before and its very confusing. i was wondering which is easier/better to do that way or vb's.

also i was look at vb's code:
PHP Code:

    $iforumcache = array();

    if (
$getinvisibles// get all forums including invisibles
    
{
        foreach(
$forumcache AS $forumid => $forum)
        {
            
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
        }
    }
    else 
// get all forums except invisibles
    
{
        foreach(
$forumcache AS $forumid => $forum)
        {
            if (
$forum['displayorder'] AND ($forum['options'] & $_FORUMOPTIONS['active']))
            {
                
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
            }
            else
            {
                unset(
$forumcache["$forumid"]);
            }
        }
    }
    
// do some sorting (instead of sorting with MySQL and causing a filesort)
    
foreach($iforumcache AS $parentid => $devnull)
    {
        
ksort($iforumcache["$parentid"]); // sort by display order
    
}
    
ksort($iforumcache); // sort by parentid (not actually sure if this is necessary) 

i have never used ksort but ill assume its sorting it by parentid first then display?

also is childlist used at all in actually building the forum list/index?

Velocd 10-09-2004 07:13 PM

ksorts sorts an array by its keys, so sorting $iforumcache[$parentid] sorts that array by displayorder.

I'm not certain what childlist is for. Maybe in building search indexes or something.

vBs way is fine, and probably easier to manipulate in PHP quickly. Less implementation would be using the way I explained in my previous post, since you don't have to rebuild a parentlist whenever a forum is relocated.

AN-net 10-11-2004 12:25 PM

i was looking at that article and it says the recursion method is slow and query wasting, now the other method tree something seems better. i just wanted to know are there anyother besides recursion, tree, and vb's method to doing this?

and which did u you guys choose?

AN-net 10-14-2004 04:51 PM

could such a system also be used in a family tree type situation?


All times are GMT. The time now is 10:59 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01060 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete