Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2009, 11:25 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-24-2009, 12:15 AM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$vbulletin->forumcache has an array of all forums, and I believe it's global too.
Reply With Quote
  #3  
Old 07-24-2009, 02:11 AM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!!!
Reply With Quote
  #4  
Old 07-24-2009, 04:30 PM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's a variable. Printing the output might help you out:
PHP Code:
print_r($vbulletin->forumcache); 
Reply With Quote
  #5  
Old 07-24-2009, 08:42 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 07-25-2009, 04:39 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
echo '<pre>';
print_r($vbulletin->forumcache);
echo 
'</pre>';
exit; 
Reply With Quote
  #7  
Old 07-28-2009, 01:43 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 07-29-2009, 01:07 AM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 07-29-2009, 03:45 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']);
Reply With Quote
  #10  
Old 07-30-2009, 07:14 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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"
Reply With Quote
Reply

Thread Tools
Display Modes

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 06:32 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.04028 seconds
  • Memory Usage 2,250KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete