Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-29-2009, 10:28 PM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need to add a menu to the subnav with a plugin

I'm looking to add a dropdown at the beginning of the subnav in the forum and CMS.
Probably the blog too. I have the html.

For the navbar I need to enter it in two places, one for those registered and one for guests.
It will be the first item in the bar.
Same in the CMS and blog.

I can hard code it all with no problem, but need to remember if I make a change in 1 place, I need to change it in 3 or places.

In vB3 I created a plugin that stored a variable.
The variable $mymenu in this case would be the html.
Then I'd hardcode $mymenu where I needed it and edit the plugin when necessary.

Another way I used to edit templates was find and replace.

I don't understand how to do it in vB4.
I've read a couple articles on how to use the new variables.
I just don't understand it.

Perhaps I can make a plugin that stores the html as in vB3?, I still don't understand how to use that variable in a template.

Any advice?
Reply With Quote
  #2  
Old 12-29-2009, 11:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can probably write the plugin and have the contents in a variable, $mymenu, just like before and then preregister the variable for use in the navbar. That should be no problem. I think the blog and cms also use templates for the link, so you'd have to preregister it for them also. Then you'd have to edit the templates to add the variable.

PHP Code:
vB_Template::preRegister('navbar', array('mymenu' => $mymenu)); 
Reply With Quote
  #3  
Old 12-29-2009, 11:39 PM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm thinking then my plugin would need to be
Hook: process_templates_complete
PHP Code:
vB_Template::preRegister('navbar', array('mymenu' => $mymenu)); 
$mymenu='menu will go here'
Placing $mymenu in the navbar template just displays $mymenu.
Reply With Quote
  #4  
Old 12-30-2009, 02:47 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't use $mymenu anymore - you need to use the new syntax. The new syntax is {vb:raw mymenu} . Check the functions.php page where the navbar is rendered and make sure your hook is located *before* that.
Reply With Quote
  #5  
Old 12-30-2009, 10:27 PM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You don't use $mymenu anymore - you need to use the new syntax. The new syntax is {vb:raw mymenu} . Check the functions.php page where the navbar is rendered and make sure your hook is located *before* that.
Thanks,
You would think the hook should be navbits_complete, if I am reading this correctly.

PHP Code:
    ($hook vBulletinHook::fetch_hook('navbits_complete')) ? eval($hook) : false;

    return 
$code;
}

/**
* Renders the navbar template with the specified navbits
*
* @param    array    Array of navbit information
*
* @return    string    Navbar HTML
*/
function render_navbar_template($navbits)
{
    global 
$vbulletin;

    
$templater vB_Template::create('navbar');

    
// Resolve the root segment
    
$templater->register('bbmenu'$vbulletin->options['bbmenu']);

    
$templater->register('ad_location'$GLOBALS['ad_location']);
    
$templater->register('foruminfo'$GLOBALS['foruminfo']);
    
$templater->register('navbar_reloadurl'$GLOBALS['navbar_reloadurl']);
    
$templater->register('navbits'$navbits);
    
$templater->register('notices'$GLOBALS['notices']);
    
$templater->register('notifications_menubits'$GLOBALS['notifications_menubits']);
    
$templater->register('notifications_total'$GLOBALS['notifications_total']);
    
$templater->register('pmbox'$GLOBALS['pmbox']);
    
$templater->register('return_link'$GLOBALS['return_link']);
    
$templater->register('template_hook'$GLOBALS['template_hook']);

    return 
$templater->render();

I'm missing something simple.
Reply With Quote
  #6  
Old 12-30-2009, 10:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, you aren't reading that correctly. That is a function. It gets called from somewhere and that is where you would look backwards from.
Reply With Quote
  #7  
Old 12-30-2009, 11:17 PM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looking at your tab, I realize that I had this reversed. It should be
PHP Code:
$mymenu=' html here';
vB_Template::preRegister('navbar', array('mymenu' => $mymenu)); 
Still don't understand the hooks since navbit_complete and some other hooks seem to work.

But thanks! I'm on my way.
Reply With Quote
  #8  
Old 12-30-2009, 11:23 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it works, great! I could be that the hook is called right before the function is called (but it isn't obvious in the code you posted).
Reply With Quote
  #9  
Old 12-31-2009, 12:35 AM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now I'm trying to use the same plugin in the CMS subnav.
Am I able to preRegister twice within the same plugin?
I changed the variable to chapterprograms.
PHP Code:
vB_Template::preRegister('navbar', array('chapterprograms' => $chapterprograms));
vB_Template::preRegister('vbcms_navbar_link', array('chapterprograms' => $chapterprograms)); 
Reply With Quote
  #10  
Old 12-31-2009, 02:22 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, you can preregister a variable for a couple of templates in one plugin. You just need to make sure it is the proper plugin to use for each of those templates.
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 01:57 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.04345 seconds
  • Memory Usage 2,273KB
  • Queries Executed 11 (?)
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
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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