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" |
#82
|
||||
|
||||
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 .
|
#83
|
||||
|
||||
Try commenting out the $result line at the bottom. I don't know if that will work in that hook.
|
#84
|
|||
|
|||
Quote:
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); } |
#85
|
|||
|
|||
Quote:
Hook: build_navigation_array Code: PHP Code:
|
#86
|
|||
|
|||
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 |
Благодарность от: | ||
TheLastSuperman |
#87
|
||||
|
||||
What hook do they run it in?
|
#88
|
|||
|
|||
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:
|
#89
|
|||
|
|||
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&userid={userinfo.userid}&starteronly=1&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. |
#90
|
|||
|
|||
Quote:
PHP Code:
|
Благодарность от: | ||
Altari |
#91
|
|||
|
|||
Awww that works perfectly, thank you !
For guys who read : Add an id... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|