// Yes, this is all the code you need to add the example above.
ExtendedNavigations::update(array(
'name' => 'Test Tab',
'children' => array(
'URL_1' => 'Sub Link 1',
'URL_2' => 'Sub Link 1.1',
'URL_3' => 'Sub Link 1.1.1'
),
'top_level' => true // NEW FEATURE IN 1.5
));
Spoiler (vBulletin 3):
PHP Code:
ExtendedNavigations::update(array(
'name' => 'Test Tab',
'children' => array(
'Link A' => array(
'URL_1' => 'Sub Link 1',
'URL_2' => 'Sub Link 1.1',
'URL_3' => 'Sub Link 1.1.1'
)
)
));
---
Adding a navigation tab is not a new concept. There are two articles (Lynne's and Ragtek's) on vBulletin.org showing how to do this. Both solutions work, but you are reading this to learn how to do take it from workable to fast, efficient, and portable.
Let's first explore the two ways it is currently done. Let's say we want to add a 'Twitter' tab, linking to "twitter.com/xyz", on every page.
Using Lynne's method:
Plugin (hook: process_templates_complete)
The benefit to this method is that it is straightforward for static, childless tabs; if you know a little php and html, this is not too difficult to implement. The problem with this method is that everything is hard-coded. The html is static; it does not make use of the template or phrase system. If you want to change the tab and add sub-links and drop-downs, you have mess with the html to get it just right. Doing anything else is going to require advanced skills and knowledge of the navigation tab system (first article), no matter how you slice it.
Using Ragtek's method:
HTML Code:
<!-- New Template: ragtek_twitter_navbar --><li><a class="navtab" href="http://twitter.com/xyz">{vb:rawphrase twitter}</a></li>
This method addresses on some of the weaknesses of Lynne's method and inherits others. Benefits include making use of the phrase and template systems. On the other hand, this shares many of the same weaknesses on the plugin side; anything but the most simple tab is going to require advanced knowledge (second article).
The first two choices come down to either simplicity at the cost of flexibility, or flexibility at the cost of complexity. There is a way to have the best of both worlds and the worst of none.
How? The answer lies in the `LancerForHire - Extended Navigations` product.
No static html, no css classes, no new templates, no conditions. Simple. You could even drop this code in vB 3 and have a new navigation link (more in the final section).
The `ExtendedNavigations::update` function takes a variable number of arrays. Each array ($options) follows the format below.
Quote:
$options['name']
Data Type: string. Required.
This is the name of the primary tab.
$options['url']
Data Type: string. Optional if $options['script'] is set; required otherwise.
This is the url of the primary tab.
$options['top_level'](New in 1.5!)
Data Type: boolean. Optional. Default: false. This option is always/forcefully enabled in vBulletin 3.
Whether or not to use the direct menu format. See $options['children'] for more information.
$options['script']
Data Type: string. Optional if $options['url'] is set; required otherwise. This option has no effect in vBulletin 3.
This is the script that will highlight the primary tab, making the children/secondary links visible. If $options['url'] is empty, $options['url'] will be set to "{$options['script']}.php".
$options['after']
Data Type: boolean. Optional. Default: true.
Whether or not to show the primary tab after the default tabs. If set to false, the primary tab will show before the default ones.
$options['children']
Data Type: array. Optional.
The links or menus contained by the primary tab. Each array element can follow the following format:
PHP Code:
string 'Child Link Name' => string 'Child Link Url'
If $options['top_level'] is enabled, the primary tab will become a drop-down in vBulletin 4. This format is not understood by vBulletin 3.
This is not supported in vBulletin 4 if $options['top_level'] is enabled. In vBulletin 3, this is the standard format.
How do I get this?
Download the product-extended_navigations_ Xml and add it (extended_navigations) as a product dependency. Yes; that's it!
Extended Navigations is reverse compatible and can be used to add tabs to vBulletin 3 easily. To use Extended Navigations in vBulletin 3, an additional product download and dependency are required: product-extended_legacies. No code changes required.