The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vB4.2 Navigation Manager - how to discussion
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 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> 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> Pull down menu's can also be coded. Have a look at the vB source for examples. Specifically "./install/vbulletin-navigation.xml" |
#2
|
|||
|
|||
FYI, the navtab_end template hook in 4.2.0 still works the same as it did in 4.1.12.
It's the navbar that gives headaches. You can add to the navbar with a DB routine too. EDIT: But this does totally screw up dynamically built navbar links. On first glance it looks like a phrase needs to be created for each navbar link. If that's the case, the maintenance DB routines for a dynamically created link will be interesting. |
#3
|
||||
|
||||
FYI, the 'show' check can use multiple variables, so if you want a link to only appear if $show['cond1'] and $show['cond2'] are set, you add them both, separated by a dot
<show>cond1.cond2</show> Custom $show variables can be created pretty much in any hook, as the navigation is almost the last thing built, but two common ones added for the purpose are load_show_variables & load_forum_show_variables. |
3 благодарности(ей) от: | ||
AusPhotography, nhawk, Sunka |
#4
|
||||
|
||||
Quote:
May I ask why you would need dynamically created links? |
4 благодарности(ей) от: | ||
AusPhotography, ragtek, scoles15, soniceffect |
#5
|
|||
|
|||
Quote:
'user' in this case means the administrator. ie: A mod uses a portion of the information entered by the user for the navbar link, say the 'title' portion of the user entry. In order to create the navbar link in the community menu, that 'title' must be also be saved in the phrase table of vB. And then the additional navbar link must be created in the navigation table. Along with that a $show variable must be created in a plugin if the member has permission to view that link. Now because different 'titles' can have different permissions, there has to be a different $show for each menu item. That seems like a lot to go through for something that use to take a one line piece of code to throw the menu selection in the community menu in earlier versions. |
#6
|
||||
|
||||
Quote:
As far as I understand you intentions by now is that the Add-on allows the administrator to set the title for a link in the Community Menu on the Forum tab? This can easily be achived by just using the Navigation Manager to rename the link. Quote:
(Which will happen automatically if you have already added that link on your developement system, assigned in to the Add-on and exported the XML). Quote:
But again this is not different from how it worked in vB 4.1 Quote:
In vB 4.1 you had to
In vB 4.2
|
#7
|
|||
|
|||
Quote:
Here's a snippet of the code to add an application type to the community menu... Code:
while($application = $vbulletin->db->fetch_array($applications)) { if ($vbulletin->options['advapp_inmenu'] && $vbulletin->userinfo['posts'] >= intval($application['postcount']) && is_member_of($vbulletin->userinfo, explode(',', $application['usergroup'])) && $application['community'] && $application['active']) { $template_hook['navbar_community_menu_end'] .= '<li><a href="application-forms.php?appid=' . $application['appid'] . '" title="' . $application['description'] . '">' . $application['type'] . '</a></li>'; } } This reminds me of the addition of the <vb:each> in templates... Nobody is going to tell me that reading a database, parse the data to build an array, sending that array to the template and parsing it a second time is faster than bulding/formating the array and sending it in all one lump piece of data to the template. It's just not possible. Two parses take double the time. But that's a different topic. |
#8
|
||||
|
||||
Quote:
The idea behind Navigation Manager is to give the Administrator full control over the menu structure - if you are creating links dynamically at runtime (which is still possible) you are IMHO somewhat defeating that goal. Quote:
Here is a little benchmark: PHP Code:
|
#9
|
||||
|
||||
Just in case you dont bother running that benchmark, here is the result on my local test environment
Time taken for 10.000 Bit Templates: 1.2209470272064 Time taken for 10.000 Array-Elements with <vb:each>: 0.010501146316528 (over 100x faster) Success - Both methods yielded the same result data and on my remote test server ; Time taken for 10.000 Bit Templates: 1.3666188716888 Time taken for 10.000 Array-Elements with <vb:each>: 0.01978611946106 (over 70x faster) Success - Both methods yielded the same result data |
#10
|
|||
|
|||
I've already given in to the idea of having to create the menu additions in the database and have the update for that particular mod ready to be released. And those menu selections were always under the admin's control to begin with. Now they can just move them around a little more.
The bechmark isn't exactly what I was talking about. In the case of rendering bits templates I agree it's much faster. But I see people using it something like this... Code:
in PHP.. While $whatever... { $whatever_each_array[] = xpartofdata; } $templater->register('whatever'. $whatever_each_array); In template.. <ul> <vb:each whatever_each> <li>{vb:raw whatever_array_part}</li> </vb:each> </ul> Code:
In PHP... While $whatever.... { $static .= '<li>' . $whatever_array_part . '</li>' . "\r\n"; } templater->register('static', $static); in template... <ul> {vb:raw static} </ul> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|