Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
vB4.2 Navigation Manager - how to discussion
AusPhotography's Avatar
AusPhotography
Join Date: Nov 2007
Posts: 521

 

Hobart & Adelaide .au
Show Printable Version Email this Page Subscription
AusPhotography AusPhotography is offline 05-18-2012, 10:00 PM

I have vB 4.2.0 BETA 1 running in my test system.

Products that use templates/hooks to integrate with the navbar will need the following changes to work with the Navigation Manager.

Please post code snips and hints in this thread, we are all on a learning curve.

1. Remove old style navigation hooks/templates etc.

2. Create a new <navigation> section in the product XML file
(You can create the navigation in the navigation manager, linked to a product then export the product file as a skeleton)

3. Set any conditionals in a hook or in your main code
Eg. $show['apmgtug'] = true; is set for one of the menu items in my example
My example relies on $show['member'] = true; as well.
Leave the <show> tag empty for 'public' tabs/links

4. If you have multiple scripts, leave <scripts> blank and set $root at the new hooks set_navigation_tab_fallaback or set_navigation_tab_vbview

Code:
if (<some condition>) $root= '<name of tab>';
I hope that helps you get a quick leg up for this change.

I would probably have a new vB4.2 code base because of the differences, you could have the same code base with some sort of version check.

In the end the new navigation integration is better and easier.

Here are sample <navigation> from one of my own plugins...

Code:
	<navigation>
		<tab name="aptab_competition" date="1337135420" username="APcompetition" version="3.0.0">
			<active>1</active>
			<show>member</show>
			<scripts>apcompetition</scripts>
			<displayorder>30</displayorder>
			<url><![CDATA[apcompetition.php{session.sessionurl_q}]]></url>
		</tab>
		<link name="aplink_enter" date="1337135420" username="APcompetition" version="3.0.0">
			<active>1</active>
			<show>member</show>
			<parent>aptab_competition</parent>
			<displayorder>20</displayorder>
			<url><![CDATA[apcompetition.php{session.sessionurl_q}]]></url>
		</link>
		<link name="aplink_search" date="1337135420" username="APcompetition" version="3.0.0">
			<active>1</active>
			<show>member</show>
			<parent>aptab_competition</parent>
			<displayorder>40</displayorder>
			<url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=search&apmycomps=1]]></url>
		</link>
		<link name="aplink_performance" date="1337135420" username="APcompetition" version="3.0.0">
			<active>1</active>
			<show>member</show>
			<parent>aptab_competition</parent>
			<displayorder>60</displayorder>
			<url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=performance]]></url>
		</link>
		<link name="aplink_fame" date="1337135420" username="APcompetition" version="3.0.0">
			<active>1</active>
			<show>apmgtug</show>
			<parent>aptab_competition</parent>
			<displayorder>80</displayorder>
			<url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=finalvotereport]]></url>
		</link>
	</navigation>
Sample phrases the give the text of the navigation items.
Code:
		<phrasetype name="GLOBAL" fieldname="global">
			<phrase name="vb_navigation_tab_aptab_competition_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Competitions]]></phrase>
			<phrase name="vb_navigation_link_aplink_enter_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Enter a Competition]]></phrase>
			<phrase name="vb_navigation_link_aplink_search_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Search Competitions]]></phrase>
			<phrase name="vb_navigation_link_aplink_performance_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[My Performance]]></phrase>
			<phrase name="vb_navigation_link_aplink_fame_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Hall of Fame]]></phrase>
		</phrasetype>
--------------- Added [DATE]1337391078[/DATE] at [TIME]1337391078[/TIME] ---------------

Pull down menu's can also be coded.
Have a look at the vB source for examples.
Specifically "./install/vbulletin-navigation.xml"
Reply With Quote
  #82  
Old 05-29-2012, 04:44 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very good discussion and imo the first post and info that follows by everyone else makes this worthy of being a Article! I moved this thread here to the articles forum, there is a 7 day redirect link in programming discussions and normally I don't do redirects but just in case some look there first in the next few days .
Reply With Quote
  #83  
Old 05-29-2012, 04:48 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try commenting out the $result line at the bottom. I don't know if that will work in that hook.
Reply With Quote
  #84  
Old 05-29-2012, 05:36 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo View Post
Try commenting out the $result line at the bottom. I don't know if that will work in that hook.
I don't really know what did u expect but of course this code with $result = commented, do nothing :
Code:
global $show;
if ($show['member'] == TRUE) 
{ 
    $userid = vB::$vbulletin->userinfo['userid'];
    $lien_messujets = array( 
        'name' => 'rescue_messujets', 
        'navtype' => 'link', 
        'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',
        'active' => 1, 
        'productid' => 'rescue', 
        'text' => 'Mes sujets', 
    ); 
    //$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;
    unset($userid);
}
(tested in build_navigation_array and navigation_tab_complete, with and without the comment)
Reply With Quote
  #85  
Old 05-29-2012, 05:48 PM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Altari View Post
Hello,

Thank you for your help,
But this doesn't work better : I added the global show and change template hook, but nothing happen. I use VBOptimise(?), but i flushed the cache, cleared system cache etc... Nothing works like that

Anyway, i'm just trying to add this to start, and it doesn't work :
PHP Code:
global $show;
if (
$show['member'] == TRUE

    
$lien_messujets = array( 
        
'name' => 'rescue_messujets'
        
'navtype' => 'link'
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',
        
'active' => 1
        
'productid' => 'rescue'
        
'text' => 'Mes sujets'
    ); 
    
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;

Try This Code

Hook: build_navigation_array
Code:

PHP Code:
if (vB::$vbulletin->userinfo['userid']) 
{
$lien_messujets = array(  
        
'name' => 'rescue_messuje',  
        
'navtype' => 'link',  
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread'
        
'active' => 1,  
        
'text' => 'Message',
        
'productid' => 'vbulletin',  
    );  

$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messuje'] = $lien_messujets;

You can replace vbulletin with your product id but make sure that product is enabled otherwise link will not be shown.
Reply With Quote
  #86  
Old 05-29-2012, 06:36 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A while back I commented about using the database method for adding things to the navigation menu and nobody has shown how to do that.

So, here's my method broken out and heavily commented so it's easy to understand....

Code:
// ########## CREATE NEW NAVIGATION ITEMS ##########
require_once(DIR . '/includes/adminfunctions_language.php');

$username = $vbulletin->userinfo['username'];
$dateline = TIMENOW;

$product = 'yourproductname';				// <<<< CHANGE TO YOUR PRODUCT NAME
$version = '1.0.0';					// <<<< CHANGE TO YOUR PRODUCT VERSION
$name = 'yourmenu_name';				// <<<< CHANGE TO WHAT YOU WANT TO NAME YOUR MENU
$varname = 'vb_navigation_menu_' . $name . '_text';	// <<<< VALID CHOICES:
							//	FOR MENUS:	vb_navigation_menu_' . $name . '_text'
							//	FOR TABS:	vb_navigation_tab_' . $name . '_text'
							//	FOR LINKS:	vb_navigation_link_' . $name . '_text'

$text = 'Text to Display';			// <<<< CHANGE TO THE TEXT YOU WANT DISPLAYED IN THE MENU
$type = 'menu';					// <<<< CHANGE TO link OR tab TO CREATE OTHER TYPES
$url = '';					// <<<< URL IS USED FOR LINK OR TAB TYPES
$fieldname = 'global';				// <<<< PHRASE GROUP NAME
$active = 1;					// <<<< 1 = SHOWN, 0 = HIDDEN
$usetabid = 0;					// <<<< 1 = APPEND TABID TO LINK, 0 = DON'T APPEND TAB ID
$edited = 0;					// <<<< SHOULD BE 0 IF NEW, 1 IF EDITED
$protected = 1;					// <<<< 1 = PROTECT FROM DELETE, 0 = ALLOW DELETE
$order = 20;					// <<<< DISPLAY ORDER
$parent = 'vbtab_forum';			// <<<< PARENT CAN BE A tab IF A MENU, A tab OR A menu IF A LINK
$permission = 'searchbuttons';			// <<<< CAN BE A VB PERMISSION OR A $SHOW['xyz'] VALUE
$scripts = '';					// <<<< SCRIPT FOR WHICH A TAB WILL BE DISPLAYED AS ACTIVE TAB
$language = '-1';				// <<<< DEFAULT = -1 OTHERWISE LANGUAGE ID NUMBER

$vbulletin->db->query_write("
	REPLACE INTO " . TABLE_PREFIX . "navigation (name, productid, navtype, fieldname, state, displayorder, parent, scripts, showperm, url, version, username, dateline)
	VALUES('" . $name . "',
		'" . $product . "',
		'" . $type ."',
		'" . ($active ? NAV_ACTIVE : 0) . "' | '" . ($edited ? NAV_EDITED : 0) . "' | '" . ($protected ? NAV_PROTECTED : 0) . "' | '" . ($usetabid ? NAV_USETABID : 0) . "',
		'" . $order . "',
		'" . $parent . "',
		'" . $scripts . "',
		'" . $permission . "',
		'" . $url . "',
		'" . $version . "',
		'" . $username . "',
		'" . $dateline . "')
	");

$vbulletin->db->query_write("
	REPLACE INTO " . TABLE_PREFIX . "phrase (varname,languageid,fieldname,text,product,username,dateline,version) 
	VALUES('" . $varname . "', 
		'" . $language . "',
		'" . $fieldname . "',
		'" . $text . "',
		'" . $product . "',
		'" . $username . "',
		'" . $dateline . "',
		'" . $version . "')
	");

build_language();	// <<<< IMPORTANT - NEW ITEMS WON'T DISPLAY WITHOUT THIS
Reply With Quote
Благодарность от:
TheLastSuperman
  #87  
Old 05-29-2012, 06:47 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What hook do they run it in?
Reply With Quote
  #88  
Old 05-29-2012, 06:54 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Badshah93 View Post
Try This Code
...
Hello,

Thank you for your help.
You code works, but only for one link. When i want to add more than 1 link, only the last is displayed.
Tested with this code :
PHP Code:
if (vB::$vbulletin->userinfo['userid']) 
{
$userid vB::$vbulletin->userinfo['userid'];
$lien_messujets = array(  
        
'name' => 'rescue_messujets',  
        
'navtype' => 'link',  
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread'
        
'active' => 1,  
        
'text' => 'Mes sujets',
        
'productid' => 'vbulletin',  
    );  
$lien_mesmessages = array( 
    
'name' => 'rescue_mesmessages'
    
'navtype' => 'link'
    
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Post&showposts=1',
    
'active' => 1
    
'productid' => 'vbulletin'
    
'text' => 'Mes messages'
); 
$lien_mesannonces = array( 
    
'name' => 'rescue_commu_annonces'
    
'navtype' => 'link'
    
'url' => '{options.toppath}member.php?u='.$userid.'&tab=afficher_annonces',
    
'active' => 1
    
'productid' => 'vbulletin'
    
'text' => 'Mes annonces'
); 
    
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_commu_annonces'] = $lien_mesannonces;
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_mesmessages'] = $lien_mesmessages;
unset(
$userid);

Reply With Quote
  #89  
Old 05-29-2012, 06:57 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo View Post
What hook do they run it in?
It can be run anywhere, in PHP code, or any other hook they want.

I use it in both PHP code for dynamic menus added by an admin from inside a mod and in the admin_options_processing_build hook for adding menus defined by the settings group for a mod.

If you use it in the admin_options_processing_build hook, add a !$settings['dummyvar'] condition at the beginning of the code and set $settings['dummyvar'] to 1 at the end of the code so it only runs once when the settings are updated.

Of course the variables would have to be gotten from the $settings['xyz'] values from the mod settings and/or some hard coded into the plugin.

EDIT: The advantage to using the database for menu items is there aren't any plugins required once the menu is created. vB itself will generate them for you at the proper time. That should be a BIG HINT for the discussion above and below this post that's revolving around a plugin to create a menu that on the surface appears to be a fixed menu that can accept variables (ie: {userinfo.userid} ). Create it once in settings or some other method and forget about it until it needs to change. Which I don't see that happening very often.

Code:
{options.toppath}search.php?do=finduser&amp;userid={userinfo.userid}&amp;starteronly=1&amp;contenttype=vBForum_Thread


I do not suggest the database method for navigation items where the displayed text for the navigation item changes frequently (the name of the item ie: Forum or What's New) or where the link is not a fixed link with variables.
Reply With Quote
  #90  
Old 05-29-2012, 07:05 PM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Altari View Post
Hello,

Thank you for your help.
You code works, but only for one link. When i want to add more than 1 link, only the last is displayed.
Try this code

PHP Code:
if (vB::$vbulletin->userinfo['userid'])  

$userid vB::$vbulletin->userinfo['userid']; 
$lien_messujets = array(   
        
'name' => 'rescue_messujets',   
        
'navtype' => 'link',   
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',  
        
'active' => 1,   
        
'text' => 'Mes sujets'
        
'productid' => 'vbulletin',
        
'navid' => 1   
    
);   
$lien_mesmessages = array(  
    
'name' => 'rescue_mesmessages',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Post&showposts=1',
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes messages',
    
'navid' => 2  
);  
$lien_mesannonces = array(  
    
'name' => 'rescue_commu_annonces',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}member.php?u='.$userid.'&tab=afficher_annonces'
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes annonces',
    
'navid' => 3  
);  
     
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_commu_annonces'] = $lien_mesannonces
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_mesmessages'] = $lien_mesmessages
unset(
$userid); 

compare it with your code, you will know why it was not working earlier.
Reply With Quote
Благодарность от:
Altari
  #91  
Old 05-29-2012, 07:42 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Badshah93 View Post
...
Awww that works perfectly, thank you !
For guys who read : Add an id...
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:42 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04888 seconds
  • Memory Usage 2,398KB
  • Queries Executed 26 (?)
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
  • (6)bbcode_code
  • (4)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (6)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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