Back to vBulletin 4 Articles

[HOW TO - vB4] Create a New Tab in the navbar (with template)
by ragtek 18 Nov 2009
Rating: (2 votes - 5.00 average)

I know that lynne allready postet an article, but here's a other way:

This tutorial will show you, how to add own links to your navbar.
(In the tutorial i'll use the code for my news add-on)

1. create a template (ragtek_news_navbar)
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
<li class="selected">
    <a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
</vb:if>
2. Create a plugin at the hook process_templates_complete
PHP Code:
if (THIS_SCRIPT == 'xxx')  // also defined('ragteknews') possible
{
//set selected tab
    
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render(); 
As you see, i've defined "ragteknews" on my news.php page.If ragteknews is defined, $vbulletion->options['selectednavtab'] will be set to ragteknews.
Thats important because where using a condition in the template:
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
Attached Thumbnails
Click image for larger version
Name:	Forums_1258596385528.png
Views:	2697
Size:	7.9 KB
ID:	106377   Click image for larger version
Name:	Forums - News_1258596373538.png
Views:	3072
Size:	11.1 KB
ID:	106378  

vblts.ru supports vBulletin®, 2022-2024