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 02-10-2012, 07:05 AM
doob doob is offline
 
Join Date: Dec 2009
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default multiple navbar versions for different sections of site

I'm trying to accomplish having totally different navbars for different sections of the site. I.e different dimensions, placement, links, etc.

I've tried copying the current navbar template to an external php file and then using a plugin to include that file into various templates.

That works fine, but some of the functions built into the navbar template stop working such as things like $vbphrase and $vboptions.

I saw in the docs that making calls to default vbulletin variables from an includes might not work, so maybe that is the problem.

Some of the phrases are easy enough to just replace with text and remove the variable, but I'm not keen on re-writing the navbits structure.

I also don't think having two different styles will work because I'm not using different navs on different forums, but rather different sections such as user profiles, groups, etc.

Too keep this simple, if I just copy the current navbar template into an external file, load that up to the site, create a plugin for the includes and then insert the variable for that includes, i.e. $includeCustomNav into a template such as albumList as a replacement for the default $navbar, what would I need to do to make that work? What am I missing??

Thanks for any help!
Doob
Reply With Quote
  #2  
Old 02-11-2012, 02:21 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try putting something like

Code:
global $vbphrase, $vboptions;

in your code? Do you know if $vbphrase is completely undefined, or just doesn't contain the phrases you want to use? Also, some things might depends on which hook location you're using.
Reply With Quote
  #3  
Old 02-14-2012, 06:54 AM
doob doob is offline
 
Join Date: Dec 2009
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think this puts me on the right track, but I need some more help with the syntax. I think you are suggesting that I need to specifically tell vbulletin to load the global variables found in the new navbar code.

I inserted this into my code but it doesn't work. I suspect I'm missing some bit of syntax.

global $vbphrase, $stylevar, $navbits, $foruminfo, $ad_location;

Also, the plugin for the includes is at the global_start hook location.

Any help on getting this to work will be great since I think I'll need to use this approach quite a bit in the future...
Reply With Quote
  #4  
Old 02-14-2012, 11:17 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by doob View Post
I think this puts me on the right track, but I need some more help with the syntax. I think you are suggesting that I need to specifically tell vbulletin to load the global variables found in the new navbar code.
It's actually a php thing. Sometimes if you want to use variables that were defined somewhere else you have to tell it you want to use the "global" variables. But what you have is correct syntax, and at the hook global_start all your variables should be global, so that isn't your problem.

There's code in different places that makes the navbar work, so I figure that you're missing some of that in your external file. What does the file do exactly?
Reply With Quote
  #5  
Old 02-14-2012, 11:47 AM
doob doob is offline
 
Join Date: Dec 2009
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My goal is to have multiple navbar layouts and then depending on the section of the site use different layouts. I know I can achieve this other ways, but I think for my purposes having the navbar as an external file and then using an includes is the best way to go.

My steps for testing:

1) copy default navbar template
2) create a new file called newNav.php and paste contents from step 1
3) create plugin for includes at global_start with var name $newNav
4) open a template such as album_pictureview and replace $navbar with $newNav

Now go to site and view an individual picture (because we're talking about album_picture view) and it will have the new navbar (which looks just like the original navbar) except that any of the global vbulletin variables aren't working.

I tried putting this in the newNav.php document, but it doesn't seem to do a thing.

<?php global ($vbphrase, $stylevar, $navbits, $foruminfo, $ad_location);
?>
Reply With Quote
  #6  
Old 02-14-2012, 01:44 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need the parens, what you had before was OK. But it doesn't do any good to declare a variable as global if it's not defined. I suspect your problem is that those variables haven't been set to any value yet when the global_start hook code is run. You would need to figure out where those variables get set and either find a different hook or set them yourself.
Reply With Quote
  #7  
Old 02-16-2012, 05:04 AM
doob doob is offline
 
Join Date: Dec 2009
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there any way to figure out what hook a default template is on? In this case the navbar template.
Reply With Quote
  #8  
Old 02-16-2012, 12:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by doob View Post
Is there any way to figure out what hook a default template is on? In this case the navbar template.
I'm not sure how to answer that because templates aren't "on hooks", at least the way I understand things. It's possible that you're just using the words differently. In any case, the navbar template is different as compared to the header template, for instance, because the header template is created in one place for all pages but the navbar template isn't. So that makes what you want to do a little difficult. The only thing to do, in my opinion, when you're trying to do anything of any coplexity, is to look at the vb code to see how it works and where the hook locations are.

It might be possible for you to include extra navbar templates by creating a plugin at cache_templates and adding your custom templates to the $globaltemplates array, then replace the navbar template in the template cache at the global_start hook. Something like:

cache_templates:
Code:
$globaltemplates = array_merge($globaltemplates, array('custom_navbar_1', 'custom_navbar_2'));

global_start:
Code:
if (THIS_SCRIPT == 'showthread') {
   $vbulletin->templatecache['navbar'] = $vbulletin->templatecache['custom_navbar_1'];
}
else if  (THIS_SCRIPT == 'forumdisplay') {
   $vbulletin->templatecache['navbar'] = $vbulletin->templatecache['custom_navbar_2'];
}

I haven't actually tried the above so it's a bit of a guess.

BTW, I see you started a couple other threads with these questions, which is fine - I'll leave those to someone else who might be able to give you a better answer.
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 05:55 AM.


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.03986 seconds
  • Memory Usage 2,232KB
  • 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
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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