vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Howto get your forum list into a script array (never been done methinks) (https://vborg.vbsupport.ru/showthread.php?t=219304)

carcomp 07-23-2009 11:25 PM

Howto get your forum list into a script array (never been done methinks)
 
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.

Code:

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:
PHP Code:

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 [DATE]1248482616[/DATE] at [TIME]1248482616[/TIME] ---------------

Sooooo... I've written this into a plugin..

Code:

$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

PHP Code:

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 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

PHP Code:

$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.

[high]* carcomp goes to read the vbulletin API some more.[/high]


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!)
Code:

$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):
PHP Code:

unset($forumid$forum); 



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

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.00998 seconds
  • Memory Usage 1,748KB
  • 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
  • (3)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)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