View Full Version : Howto get your forum list into a script array (never been done methinks)
carcomp
07-23-2009, 11:25 PM
Hey all. Once again, I am working on coding one of the coolest things I can think of. I'm working on what I would like to call "the ultimate navbar"...
It floats, has dropdown css menus, its CENTERED (how did I do that ;) and it stays docked at the top of the screen.
Go to www.quad4forums.com and select the test theme for a demo of what i've got so far.
Now here's my question:
How do I get a list of forums into an array? I plan on using the array later as a dropdown list of forums that the user can click on.
I planned on basing it somewhat after my scrolling latest threads thing. It uses the following code (heres the important part) and its really cool.
for (Y; Y >-1; Y--)
{
pausecontent2[Y]=q[Y]+' - <a href=\"showthread.php?t='+threads[Y].threadid+'\"><B>Recent Thread - <I>'+threads[Y].title+'</I></A></b> (Posted By: '+threads[Y].poster+' on '+threads[Y].threaddate+')'
}
I just can't get a forum list. I don't really want outputted html, just something where I can do the following... (its in pseudocode)
for X = 1 to ubound(forumcount)
arrayForumName(X) = forumsomefile.php?somecommand=x
arrayForumURL(X) = forumsomefile.php?somecommand=x
next x
Can this be done? Do I just need to drag it from the database using SQL commands? UGH why is such a simple thing so hard to do.
BTW: $forumjump doesn't work in the navbar or header
Deceptor
07-24-2009, 12:15 AM
$vbulletin->forumcache has an array of all forums, and I believe it's global too.
carcomp
07-24-2009, 02:11 AM
Excellent reply! I am currently googling the topic. If you care to parallel my searching, how exactly do I go about using that? Is it a template thing, or more of a plugin thing?
My first google search of $vbulletin->forumcache was pretty useless. Searching continues...
-- Edit: just found out that its a plugin thing. Gonna try to do some template dumps --
--EDIT #2: I think i'm going to need a lot of walkthroughing!!!
Deceptor
07-24-2009, 04:30 PM
It's a variable. Printing the output might help you out:
print_r($vbulletin->forumcache);
carcomp
07-24-2009, 08:42 PM
cripes! page after page! How do i get it to print in a column?
--------------- Added 1248482616 at 1248482616 ---------------
Sooooo... I've written this into a plugin..
$find = 'hoobajoob';
foreach( $vbulletin->forumcache as $key => $value){
$replace = $replace . "KEY: $key, VALUE: $value<br />";
}
$vbulletin->templatecache['navbar'] = str_replace($find, $replace . $find, $vbulletin->templatecache['navbar']);
Now all I get is "KEY: 34 VALUE: ARRAY" over and over.
How do I break it down one more level so I can see whats in all of those arrays? I've been trying with "foreach() but it just gives me php errors.
Dismounted
07-25-2009, 04:39 AM
echo '<pre>';
print_r($vbulletin->forumcache);
echo '</pre>';
exit;
carcomp
07-28-2009, 01:43 PM
What I'm trying to do is put my forums names and their links into one of my dropdown menus. (Custom ones I wrote in java, not the vbMenu ones) You can check it out at www.quad4forums.com (http://www.quad4forums.com) and choose the Test Theme.
I've followed along everything you've said so far, but getting into the deeper dimensions of this multi-dimensional array (forumcache) is getting the better of me.
I'm going to google some more. If you feel like explaining how to pull the forum names from the forumcache and put them into a <pre> list, you'll be teaching a man how to fish.
Deceptor
07-29-2009, 01:07 AM
$simple_array = array();
foreach ($vbulletin->forumcache as $forumid => $forum)
{
$simple_array[$forumid] = $forum['title'];
}
That will create a simple array, the key will be the forum id while the value is the forum title. Hopefully that makes things easier for you :)
carcomp
07-29-2009, 03:45 PM
Thank you. I feel kinda silly. My internet connection died right when I was typing a response that I had searched for more threads by you with search terms like "forumcache" and found out the answer somewhat. What you have just told me is WAY more exact though.
Thanks.
EDIT:
Is there some sort of shortcut to figuring out who has permissions for what? I just print_r'd vbulletin->userinfo['permissions'] and it looks like i'd have a do a comparison of every forum permissions to each users permissions manually (a for-each thing). We have a lot of different usergroups (such as premium users, probationary, etc) and I want to write something that doesn't need to be added to each time we create or delete a usergroup.
* carcomp goes to read the vbulletin API some more.
Edit:
OK awesome, its working so far. I can get a list of forums based on user permissions. Now I just have to figure out if a forum is a child or not (so the menus can cascade!)
$find = '$hoobajoob';
$simple_array = array();
foreach ($vbulletin->forumcache as $forumid => $forum)
{
if($vbulletin->userinfo['forumpermissions'][$forumid] & $vbulletin->bf_ugp_forumpermissions['canview']) {
$simple_array[$forumid] = $forum['title'];
$huh = $huh . '<br /> ' . $forum['title'];
}
}
$vbulletin->templatecache['navbar'] = str_replace($find, '<pre>' . $huh . '</pre>' . $find, $vbulletin->templatecache['navbar']);
carcomp
07-30-2009, 07:14 PM
Ok dern it now why when this is enabled, can my users not see any forums? Its like its changing their permissions.
I have the plugin in "cache_templates"
MAORBARI
07-30-2009, 08:05 PM
there is function:
construct_forum_jump();
Deceptor
07-31-2009, 03:54 PM
Carcomp, it's possible one of the variables used is messing some internal code up later, try adding this to the end of your code (I highly doubt the other variables declared are doing anything):
unset($forumid, $forum);
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.