Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2004, 05:19 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 10-09-2004, 06:24 PM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 10-09-2004, 06:28 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im talking about how the actual functions in /includes/functions_forumlist.php detect/know if its a category and how to group them
Reply With Quote
  #4  
Old 10-09-2004, 06:33 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 10-09-2004, 06:39 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 10-09-2004, 07:00 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 10-09-2004, 07:05 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #8  
Old 10-09-2004, 07:13 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 10-11-2004, 12:25 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 10-14-2004, 04:51 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:29 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04367 seconds
  • Memory Usage 2,266KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete