View Full Version : $forum array... where?
mdevour
02-19-2006, 11:59 PM
I'm trying to understand the code better before attempting a modification to the forumhome_forumbit_level1_nopost template.
Where does the $forum array variable come from? Where is it declared, initialized, assigned values, whatever? What is its scope? What does it contain?
As far as I can tell, the Code Documentation in the Members Area does not include an index by variable, so how else can I find information about them?
What is a better way to answer this question for myself, rather than asking random questions like this on the forum? I'm barely starting to understand PHP, so I don't know the tools or techniques yet. Please point me in the right direction!
Thanks!
Mike D.
Andreas
02-20-2006, 12:19 AM
Best way: Lookup where the Template (forumhome_forumbit_level) is being called, and you will see the context, scope of variables, etc.
Hint: construct_forum_bit() in functions_forumlist.php
mdevour
02-20-2006, 01:03 AM
Thank you for your time, Andreas.
I've already traced program flow all the way from index.php down to construct_forum_bit()... But at that point the $forum array is being used heavily, having already been declared and assigned values. I need to see the part of the code where it's created.
I am very early in my effort to pick apart the vBulletin code base. I am beginning to be able to read PHP, though I'd be hard pressed to write it. I don't have a clue where I should begin to look, in this stack of dozens of php files, for the place where $forum is created and initialized (or modified).
Should I drop to a linux command line and grep something like '$forum = array'??? Or is there a framework for how the coders organized things that I need to know more about?
I'm trying to get to the point where I can answer questions like this for myself, so any foundational information you can see that I'm lacking, I would welcome.
Thanks again,
Mike D.
Andreas
02-20-2006, 01:17 AM
In construct_forum_bit you can find this line:
$forum = $vbulletin->forumcache["$forumid"];
$vbulletin->forumcache is the unserialized array from table datastore, title = forumcache
The cache is build from table forum by build_forum_permissions() in includes/adminfunctions.php, when a forum is added/modified, permissions changed, etc.
As this is cached data, it does not necessarily contain the current values for replies, threads, etc.
This is where cache_ordered_forums() comes into play:
It reads the current data from table forum (and other tables if necessary), merges them into $vbulletin->forumcache
To answer such questions yourself, you have to track down the data flow.
mdevour
02-20-2006, 02:11 AM
D'oh!
And if I hadn't read past the line in construct_forum_bits() that calls fetch_last_post_array(), I'd have been able to find out where $forum was defined by looking up fetch_last_post_array() in the Code Documentation, which would have gotten me to look in functions_forumlist.php again, about 3 screenfuls above where I was at already. <sigh>
Okay, now I just have to study build_forum_permissions() to get my bearings on what they're putting in the cache.
This is excruciating.
To answer such questions yourself, you have to track down the data flow.You're absolutely right. Thanks, Andreas.
Mike D.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.