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
  #22  
Old 05-20-2012, 03:19 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
But if it's not a static link? I'm supposed to tell user's to do it themselves now because vBulletin thinks they want more control over their navbar? Respectfully, most user's do not want total control, they want things done for them.

I've come up with this code, it's not efficient but it works, I will work on efficiency-

nhawk I know you mentioned making a database change but I prefer to avoid db edits if possible.

This example adds a link to Quick Links
No phrase needed.

On navigation_tab_complete hook:

PHP Code:
//Quick Links Add in 4.2.0 Start
  
foreach ($tabdata AS $key => &$thistab)
  {
   if (
is_array($thistab['children']))
   {
    foreach (
$thistab['children'] AS &$ttab)
    {
     if (
$ttab['name'] == 'vbmenu_qlinks')
     {
       
$nl['root']  = $key;
       
$nl['type']  = 'link';
       
$nl['url']    = 'myfile.php';
       
$nl['title']  = 'Link Title';
       
$nl['name']  = 'custom_name_here';
       
$nl['children'] = 0;
       
$ttab['children'][] =  $nl;
     }
    }
   }
  }
//Quick Links Add 4.2.0 END 
Mind you that needs to be run for each new link which itself will likely be some kind of loop.
I thought of doing it that way, an actually had it done that way. But then there's no control by the admin as to where it goes (as pointed out by Andreas) and I changed to the DB write.

The advantage of doing it in the DB is the admin can move it around to any menu once it's created. After working with it a bit, I found management really isn't difficult. It's only a couple of DB writes at application type creation (in my mod) and then I'm done with it. No need to parse out a special template or anything else in vB 4.2.

And the nice thing is that when the product is uninstalled, the navigation and phrase info gets deleted like it should.
Reply With Quote
  #23  
Old 05-20-2012, 03:56 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
The advantage of doing it in the DB is the admin can move it around to any menu once it's created. After working with it a bit, I found management really isn't difficult. It's only a couple of DB writes at application type creation (in my mod) and then I'm done with it. No need to parse out a special template or anything else in vB 4.2.

And the nice thing is that when the product is uninstalled, the navigation and phrase info gets deleted like it should.
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it
Reply With Quote
  #24  
Old 05-20-2012, 07:13 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it
Voted... But I do think it's working logically now, consistent with plugins and templates. Seems like nav elements should have a special setting though.
Reply With Quote
  #25  
Old 05-20-2012, 09:03 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Consistent with Plug-ins, yes - but not consistent with how it worked in previous vBulletin versions:

In previous versions Add-ons usually added their links into the Navbar by rendering their own templates on a certain template Hook.

If the Administrator modified those templates (eg. if he added another link), an upgrade of the Add-on would not overwrite this modification - the link would still be there after an upgrade.

Most items (Settings, Cron-Jobs, FAQ, Admin-Help, etc.) do have a volatile flag to handle "custom items" on upgrades, and this is what is missing here.
Reply With Quote
  #26  
Old 05-20-2012, 09:05 PM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
But if it's not a static link? I'm supposed to tell user's to do it themselves now because vBulletin thinks they want more control over their navbar? Respectfully, most user's do not want total control, they want things done for them.

I've come up with this code, it's not efficient but it works, I will work on efficiency-

nhawk I know you mentioned making a database change but I prefer to avoid db edits if possible.

This example adds a link to Quick Links
No phrase needed.

On navigation_tab_complete hook:

PHP Code:
//Quick Links Add in 4.2.0 Start
  
foreach ($tabdata AS $key => &$thistab)
  {
   if (
is_array($thistab['children']))
   {
    foreach (
$thistab['children'] AS &$ttab)
    {
     if (
$ttab['name'] == 'vbmenu_qlinks')
     {
       
$nl['root']  = $key;
       
$nl['type']  = 'link';
       
$nl['url']    = 'myfile.php';
       
$nl['title']  = 'Link Title';
       
$nl['name']  = 'custom_name_here';
       
$nl['children'] = 0;
       
$ttab['children'][] =  $nl;
     }
    }
   }
  }
//Quick Links Add 4.2.0 END 
Mind you that needs to be run for each new link which itself will likely be some kind of loop.
does 'name' key exist in tabdata[children] array, because when i print_r the tabdata array i did not find a word called "name" anywhere.

Well i liked vb 4.2.0 navigation manager and specially for my new mod. Yes i still have to create one plugin which i was doing in earlier version also but i won't have to create new template for it to use vb:each function.

i am creating a new mod which has one tab and under which there are 5 menu by default. (which i will create it through navigation manager)
there are 3 menu who's links are not fixed, it changes for each usergroup, so i will be creating array of links for those menus which i was for doing in earlier version also.

i don't know how others are going to place their dynamic links inside menu, but i will be doing this way

Plugin Hook: set_navigation_tab_main
PHP Code:

if (THIS_SCRIPT == 'myscript')
{

$rootid $roots['mytabname'];   
$x build_navigation_list(true$rootidfalse); // building mytabname list only

// An Array with menu name = $key and value = links array 
(ex: array([menu1] => array([0]=> array('title' => 'google''url' => 'google.com'
[
1]=> array('title' => 'vbulletin''url' => 'vbulletin.com')) [menu2] => (link array for menu2))

foreach (
$array AS $menuname => $linkarray)
{

$menuchild $x["$rootid"]["links"]["$menuname"]["navid"];

$tabs["$rootid"][children]["$menuchild"][children] = array_merge($tabs["$rootid"][children]["$menuchild"][children], $linkarray);

}


Benefits of this method:

1) admin can add new menu inside "mytabname" easily through navigation manager
2) admin can add new links inside any menu. (even those menu which have dynamic links)
3) admin can change displayorder, title of any menu.
4) admin can change title of any links through navigation. (for dynamic links through phrase manager)
5) it hardly effects overall performance. (.1 extra second)
Reply With Quote
Благодарность от:
Hippy
  #27  
Old 05-21-2012, 11:07 AM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it
Voted.

But a workaround for that is to create another product that only contains navigation items. Then the navigation items don't get overwritten if the main product is updated.
Reply With Quote
  #28  
Old 05-21-2012, 11:29 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, that would work but doesn't seem that user friendly

Another workaround would be to do some installation code trickery to add already existing items to the XML data.
Reply With Quote
  #29  
Old 05-21-2012, 12:05 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
Yep, that would work but doesn't seem that user friendly

Another workaround would be to do some installation code trickery to add already existing items to the XML data.
I agree it's not that user friendly, but it seemed to be the most fool-proof way of doing it.

The funny thing is (if I'm reading that bug report right) if an admin adds 10 or 20 navigation tabs/menu selections to a stock vB installation using the vBulletin product as the parent, and then updates vB, all of those changes will be lost with the upgrade.

That's a bug to me! The admin will have to re-insert the changes he made each time he upgrades vB.

So that's not an improvement request.
Reply With Quote
  #30  
Old 05-23-2012, 06:52 AM
AusPhotography's Avatar
AusPhotography AusPhotography is offline
 
Join Date: Nov 2007
Location: Hobart & Adelaide .au
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is Paul M's blog on how to use the Navigation Manager

https://www.vbulletin.com/forum/entr...amp-Navigation

Kym
Reply With Quote
Благодарность от:
Hippy
  #31  
Old 05-23-2012, 08:42 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
The funny thing is (if I'm reading that bug report right) if an admin adds 10 or 20 navigation tabs/menu selections to a stock vB installation using the vBulletin product as the parent, and then updates vB, all of those changes will be lost with the upgrade.
They will not, the upgrade process does not remove any tabs/menus/links belonging to the core 'vbulletin' product.
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 09:07 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.06972 seconds
  • Memory Usage 2,378KB
  • 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
  • (3)bbcode_code
  • (3)bbcode_php
  • (7)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