Helpful Information
 
 
Category: vBulletin 4 Articles
[HOW TO - vB4] Create a New Tab in the navbar (with template)

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)

<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

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: <vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">

Can I ask where do you place the plugin?

In truth I am getting a bit lost with this, why can't the CMS simply place links where you want them, I like subdreamer's way of doing this I think!

Sorry, strange that it's gone away. I've edited my post;)

And the hook is process_templates_complete

Sorry, strange that it's gone away. I've edited my post;)

And the hook is process_templates_complete

Thank you. I hope it. :)

Man this is awesome. When I am displaying the page I created the forums tab is still highlighted....am I missing something or did I forget to change something.....

Thanks for the help!

whats your code?

Which code? The plugin code?

Plugin and template code

Very cool and simple, thanks for this.

Plug In Code:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'member_ranks')
{
$vbulletin->options['Ranks']='unique_name';
$tabselected = ' class="selected"';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="ranks.php">Ranks</a>'.$tablinks.'</li>' ;


Template Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>

{vb:raw header}

{vb:raw navbar}

<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>

<h2 class="blockhead">=MK= Member Ranks</h2>
<div class="blockbody">
<div class="blockrow">

<div>
MY CUSTOM CODE WENT HERE ( Removed to save some space)
</div>
</div>

</div>
</div>

{vb:raw footer}
</body>
</html>

Is your templace called "member_ranks" or something else?

Its called vbcms_ranks

Please tell me its not that simple.......I knew it would be something simple I was over looking...

Perfect! I didn't want to have to edit the files especially since its in beta.

Plug In Code:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'member_ranks')
{
$vbulletin->options['Ranks']='unique_name';
$tabselected = ' class="selected"';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="ranks.php">Ranks</a>'.$tablinks.'</li>' ;


Template Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>

{vb:raw header}

{vb:raw navbar}

<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>

<h2 class="blockhead">=MK= Member Ranks</h2>
<div class="blockbody">
<div class="blockrow">

<div>
MY CUSTOM CODE WENT HERE ( Removed to save some space)
</div>
</div>

</div>
</div>

{vb:raw footer}
</body>
</html>

And what's with the template for the navbar?
I think you made it completely false

vbcms_navbar_add

<vb:if condition="$vboptions['selectednavtab'] == 'Ranks'">
<li class="selected">
<a class="navtab" href="ranks.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
<vb:else />
</vb:if>

Try this:

if (THIS_SCRIPT == 'member_ranks')
{
$tabselected = ' class="selected"';
$vbulletin->options['selectednavtab'] = 'Ranks';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="ranks.php">Ranks</a>'.$tablinks.'</li>' ;

You have to set $vbulletin->options['selectednavtab'] because if it's empty vbulletin sets the forum to standard and then you have 2 "active tabs"

That didnt work.........

but it did add a light gray line at the top of the page....

Hi ragtek, thanks for the code, will use it later =)

Right now I'm trying to do something a little differente: create a tertiary navbar just below the sections navbar for the CMS page. In this tertiary navbar wil be listed the subsections for the sections in the navbar. So if there's a section named "Music" in the navbar, when clicked, the tertiary navbar wil show the subsections from "Music". It's almost the same as the Section Navigation Widget, but in the navbar and without all that java =)

Is this possible, and, how? =)

Thank you =)

Hi ragtek, thanks for the code, will use it later =)

Right now I'm trying to do something a little differente: create a tertiary navbar just below the sections navbar for the CMS page. In this tertiary navbar wil be listed the subsections for the sections in the navbar. So if there's a section named "Music" in the navbar, when clicked, the tertiary navbar wil show the subsections from "Music". It's almost the same as the Section Navigation Widget, but in the navbar and without all that java =)

Is this possible, and, how? =)

Thank you =)phuuuuuuu, very good question, but i don't know how to make it
sorry

please post "news.php" content, because i cant find how to make a selectednavtab, did what you have said, but it still doesnt work!

Hi,

http://www.vbulletin.org/forum/showthread.php?t=228112
A test.php page I've created here

New tab is not selected TEST

My bad English

For test.php please tell me?

Regards

Hi,

http://www.vbulletin.org/forum/showthread.php?t=228112
A test.php page I've created here

New tab is not selected TEST

My bad English

For test.php please tell me?

Regardswhat?

Like this http://www.vbulletin.org/forum/attachment.php?attachmentid=106378&d=1258596456

I click new tab TEST
test.php page opens
But
Forum tab will be selected

Like this http://www.vbulletin.org/forum/attachment.php?attachmentid=106378&d=1258596456

I click new tab TEST
test.php page opens
But
Forum tab will be selected
Reread part 2 of the article:
As you see, i've defined "ragteknews" on my news.php page.If ragteknews is defined, $vbulletion->options['selectednavtab'] will be set to ragteknews.

Sorry, this may very obvious, but why is there a condition?
I would want the tab to be visible whether I am viewing the CMS, Blog or forum.

EDIT: As it is always with me, I understand it a little more after posting a questions and rereading the original post.
Is the condition for when the link is selected, do some action, like go to that link?

EDIT2: How do I put a name on the tab? Do I create a phrase?
Is there anything wrong with me replacing {vb:rawphrase ragtek_news} with my tab name?

The condition is for when that tab is 'active' and the submenu shows.

The condition is for when that tab is 'active' and the submenu shows.
Ah. Similar to your new tab in nav bar?
I'm just looking to add a tab when clicked goes to another page.

Ah. Similar to your new tab in nav bar?
I'm just looking to add a tab when clicked goes to another page.
Yes, my mod and ragtek's do the same thing. We happened to each write them using a different approach to do the same thing. :)

Could someone show this noob how for example I could create 2 tabs each linking to an url? I don't understand what exactly I need to do.

any word on my issues? post #17 and the forum tab selected instead of the "Ranks" page???

Reread part 2 of the article:

sorry, but i did everything the same as explained, but the tab doesnt become "selected" when its opened.

would be great if you add a sample of your test.php, because ive searched everywhere and didnt come accross with it

please post "news.php" content, because i cant find how to make a selectednavtab, did what you have said, but it still doesnt work!
in news.php i have define(ragteknews, true); what is very important but i think that it could be solves without
template:

<template name="ragtek_news_navbar" templatetype="template" date="1258595041" username="ragtek" version="1.0.0">
- <![CDATA[ <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>
]]>
</template>

plugin at hook process_templates_complete

if (defined('ragteknews'))
{
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render();

in news.php i have define(ragteknews, true);

Thank you very much
Now okay


Regards

Thanks, this is what i needed.

define(ragteknews, true);

you must include this in your how-to

i've updated the article

Still tinkering around with this. Is it possible to define the selectednavtab for a CMS page to use with this method? For example if my news.php page was part of the CMS such as http://www.mydomain.com/content.php?5-news where would I define define(news, true); ?

<vb:if condition="$vboptions['selectednavtab'] == 'news'">

or is there a different condition I could use based on the "5-news" perhaps...

Still tinkering around with this. Is it possible to define the selectednavtab for a CMS page to use with this method? For example if my news.php page was part of the CMS such as http://www.mydomain.com/content.php?5-news where would I define define(news, true); ?

<vb:if condition="$vboptions['selectednavtab'] == 'news'">

or is there a different condition I could use based on the "5-news" perhaps...

atm i don't know this, sorry.

i wish this would be possible with vB4 ( http://www.vbulletin.com/forum/showthread.php?327787-Create-a-contentpage&p=1852507#post1852507 )^^

Your template works like a charm for my non-CMS pages - thanks for that! I will have to leave News down in the submenu bar for now and hope that they improve the ability to manage the navbar in upcoming releases.

Fantastic! Thank you for sharing. It was the only missing to finish microSUPPORT for vB4. Works like a charm and I don't have wrong highlight problems.

Maria

Fantastic! Thank you for sharing. It was the only missing to finish microSUPPORT for vB4. Works like a charm and I don't have wrong highlight problems.

Maria

haven't you wrote that you've finished with the vB Community and don't want to code anything else?

haven't you wrote that you've finished with the vB Community and don't want to code anything else?

Marketing tips my dear:)

So I've been tinkering around with this tutorial and was close to raising the white flag of surrender because I could not understand this for the life of me.
So after long grueling hours, I've manage to figure things out and get things working...well sort of.

I've used Lynne's artcle "[HOW TO - vB4] Create a own vBulletin page (http://www.vbulletin.org/forum/showthread.php?t=228112)" and managed to create an about us page.

My about us page named, "about.php" look like this...
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT', 'aboutus_plug');
define('CSRF_PROTECTION', true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('about_us',);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = construct_navbits(array('' => 'About Us'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater = vB_Template::create('aboutus_tmplt');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());
?>


My template page named, "aboutus_tmplt" looks like this...
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>

{vb:raw header}

{vb:raw navbar}

<h2 class="blockhead">About Us blockhead text</h2>
<div class="blockbody">
<div class="blockrow">
About Us text here
</div>
</div>

{vb:raw footer}
</body>
</html>
My plug-in script named, "aboutus_plug" looks like this...

if (THIS_SCRIPT == 'aboutus_plug')
{
$tabselected = ' class="selected"';
$vbulletin->options['selectednavtab'] = 'About Us';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="about.php">About Us</a>'.$tablinks.'</li>';
----------

It feels awesome when things just work!
Like they say, "If it ain't broken, don't fix it", well that's not how it is in my case because my knowledge of VB's coding is fairly basic so I feel like I may have butchered some things that weren't necessary.

What I'm concerned with is that I have no idea what this line of does in my plug-in code.
$vbulletin->options['selectednavtab'] = 'About Us';
Because I could name it, "Foo" and it will still work.
Can anyone shed some light as what that line of code does?

Also what I'm hoping for is that if anyone can please verify that the lines of code I have posted are valid giving their respective names and all?
Any help will greatly be appreciated.

Thanks.

1. because your template is called aboutus_tmplt you need $globaltemplates = array('aboutus_tmplt'); instead of $globaltemplates = array('about_us',);


the other thing i don't understand. sorry(my english is horrible :( )

Hi,

I have added the template and plugin. But there is no letters appearing in the navbar.
Can anyone help ?

My template 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>

Plugin
if (THIS_SCRIPT == 'ragteknews')
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render();

@Chee Foo

You have to define "ragtek_news" as a new Phrase in the AdminCP.
Then you will get the phrase you defined as the Tabname

You could also write "my phrase" instead of using a phrase;)

@Chee Foo

You have to define "ragtek_news" as a new Phrase in the AdminCP.
Then you will get the phrase you defined as the Tabname

What should I fill up in the fields under phrase manager ?
Phrase Type - Global ?
Product - vBulletin ?
Varname - ragtek_news ?
Text - ??

Phrase Type: Global
Varname: A varname, which you will have to use in the template
Text: Yout text which will be shown in the template

Thanks!! It works!

Works for me! Awesome, ty sir.

What about changing the order of the tabs... I see that in this example the tab is set to navtab_middle.
If I wanted to switch this tab (now in position 2 out of 3) with the default 'what's new' tab (now in position 3 out of 3)
would I state navtab_right ?

TYTY

If there's a hook, yes;)

Hey ragtek thanks for this i managed to create the button im doing an arcade on my site and did the button no probs but how do i create a page as when you press the button it leads no where im a little bit of a noob only been doing this 3 months an learning lol thanks in advance p.s i know i have to load the games to my server etc just working on that..

--------------- Added 1262146923 at 1262146923 ---------------

BTW think im getting there but i also need to add this html code to make the game work
<html>
<head>
<title>Pacman Advanced</title>
</head>
<body>
<center>
<h1>Pacman Advanced</h1>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="400">
<param name="movie" value="pacmanadv.swf">
<param name="quality" value="high">
<embed src="pacmanadv.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="400">
</embed>
</object>
<br>
<a href="http://www.startgames.ws">Online flash game</a>
</center>
</body>
</html>

Where would i add that? this is harder than i thought when i stared 12 hours ago lol.
Thanks.

--------------- Added 1262152274 at 1262152274 ---------------

Also how do i create a page for it to link to when you press the tab??

There are some articles for own pages;)
http://www.vbulletin.org/forum/forumdisplay.php?f=242

Thanks ragtek but ive looked through everything bud ive been doing this 14 hours with no sleep so getting a little tired now.
i just wanted to know how a create a page forr the button to link to.
Thanks B.

http://www.vbulletin.org/forum/showthread.php?t=228112
http://www.vbulletin.org/forum/showthread.php?t=229194

Ok great ragtek thank you very much big help think the second one is easiar but how would i direct the tab to that page sorry to be a pest but i am really new to all this and avin many sleepless nights learning while i have time off work great way to spend hols...:erm:

tx helped alot,

one problem on a board im getting these stange spacers
but only on the first line "always" as if the text is indent once.
and same result for various browsers..

108759


<li class="popupmenu">
<a href="javascript://" class="popupctrl navtab" style="background:transparent url({vb:stylevar imgdir_misc}/arrow.png) no-repeat {vb:stylevar right} center; padding-right: 10px">Gallery</a>
<ul class="popupbody popuphover">
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="http://www.google.com" target="_blank">Google</a></li>
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="http://www.google.com" target="_blank">Google</a></li>
</ul></li>

any idea ?

Is not possible for a not coder user , to use this mod :(

Will be great if one of the vb.org coder release a "Generic addon Tabs" , with a working link that just must be changed..... "Ready to use".

Is not possible for a not coder user , to use this mod :(

Will be great if one of the vb.org coder release a "Generic addon Tabs" , with a working link that just must be changed..... "Ready to use".
There already is one of those. vBH-Add Tabs.

I want to show TEST Menu Option only if $myvar is set to 1 (Usergroup Permission) but this is not working for me.
Could someone help me ?


if (THIS_SCRIPT == 'xxx') // also defined('ragteknews') possible
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'ragteknews';
$myvar=$permissions['x1'] AND $vbulletin->bf_ugp['x1']['x2']; //MY VARIABLE
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render();



<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">
<vb:if condition="$myvar"><li><a href="test.php">TEST</a></li></vb:if>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
</vb:if>


--------------- Added 1263217553 at 1263217553 ---------------

Fixed it with Lynnes Article: http://www.vbulletin.org/forum/showthread.php?t=226914

Hello,

Adapted this to create a link to my main website:

Plugin "Main Website Button", on process_template_complete:

$template_hook['navtab_middle'] .= vB_Template::create('Link to Main Website')->render();

Template "Link to Main Website":

<vb:if condition="$vboptions['selectednavtab'] == 'mainwebsite'">
<li class="selected">
<a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a></li>
</vb:if>

Enjoy!

How come when I click on the nav tab, it shows the Forum tab as selected and not the tab I created?

How come when I click on the nav tab, it shows the Forum tab as selected and not the tab I created?
Because you didn't make the condition a valid condition for your tab.

Good article. It worked well. question. if I need to add more tabs do I need to make new templates and hooks?

-CP

In case anyone is curious and you know how to create a permission group, here is how you can use that group to determine who can see the tab.

FIRST:
At the top of the plugin, add a variable for your permission group array:
$accessgroups = explode(',', $vbulletin->options['permission_group_name']);

SECOND:
At the bottom of the plugin, find the following line:
$template_hook['navtab_end'] .= vB_Template::create('template_navbar')->render();

Change it to:
$templater = vB_Template::create('template_navbar');
$templater->register('accessgroups', $accessgroups);
$template_hook['navtab_end'] .= $templater->render();

THIRD:
Open your template and add a line to the top and the bottom.
<vb:if condition="is_member_of($bbuserinfo, $accessgroups)">
</vb:if>

NOTE: I know you could just edit the current if condition with an AND, but I think that will just confuse some people.

I kind of modified this to try and use it with articles as "pages" with the tabs linked to articles.. (and it works, the tabs show as on).... but the HOME button is on too. Is there a way to set the home button to unselected?

$tabselected = '';
$tablinks = '';
if ($_GET ['r'] == '180-Roster')
{
$vbulletin->options['selectednavtab']='Roster';
$tabselected = ' class="selected"';
}
$template_hook['navtab_start'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?r=180-Roster">ROSTER</a>'.$tablinks.'</li>' ;

I finally figured out a way to add all my variables from my custom page to the navbar. I went about it in a sneaky way.

I first added the following code to my showroster.php file which allowed me to add all the registered variables I wanted to use:

$accessgroups = explode(',', $vbulletin->options['showroster_access_groups']);
$navbarloc = $vbulletin->options['showroster_navbar_loc'];

switch ($navbarloc) {
case '1':
$nbloc = 'navtab_start'; break;
case '2':
$nbloc = 'navtab_middle'; break;
case '3':
$nbloc = 'navtab_end'; break;
}

if (THIS_SCRIPT == 'showroster') {
$vbulletin->options['selectednavtab'] = 'showroster';
}

$templater = vB_Template::create('showroster_navbar');
$templater->register('sorturl', $sorturl);
$templater->register('accessgroups', $accessgroups);
$templater->register('columns', $columns);
$templater->register('sortgroupfield', $sortgroupfield);
$templater->register('oppositesort', $oppositesort);
$template_hook[$nbloc] .= $templater->render();

Since that was a close repeat to the code in my plugin, I ended up having one Roster button when on another tab and two when viewing the roster. I tried to remove the plugin, but that then caused the button to be missing when on another page; although it was there when on the roster. It makes sense after the fact. So, after some thought, I changed my plugin to the following:

if (THIS_SCRIPT != 'showroster') {
$accessgroups = explode(',', $vbulletin->options['showroster_access_groups']);
$navbarloc = $vbulletin->options['showroster_navbar_loc'];
$navbarorder = $vbulletin->options['showroster_navbar_order'];

switch ($navbarloc) {
case '1':
$nbloc = 'navtab_start'; break;
case '2':
$nbloc = 'navtab_middle'; break;
case '3':
$nbloc = 'navtab_end'; break;
}

$templater = vB_Template::create('showroster_navbar');
$templater->register('accessgroups', $accessgroups);
$template_hook[$nbloc] .= $templater->render();
}

That allowed me to use the plugin code when not on the roster page. When on the roster page, this code doesn't work, but the code from my showroster.php does. I then set up my showroster_navbar template to include the variables from my .php file and they work very well.

<vb:if condition="is_member_of($bbuserinfo, $accessgroups)">
<vb:if condition="$vboptions['selectednavtab'] == 'showroster'">
<li class="selected">
<a class="navtab" href="showroster.php{vb:raw session.sessionurl_q}">Roster</a>
<ul class="floatcontainer">
<li><a href="showroster.php{vb:raw session.sessionurl_q}">Default Sort</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Sorting Options</a>
<ul class="popupbody popuphover">
<vb:if condition="$show[field1st]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column1]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts1}</vb:if>&amp;sortgroupfield={vb:raw columns.column1}">{vb:raw columns.title1}</a></li></vb:if>
<vb:if condition="$show[field2nd]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column2]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts2}</vb:if>&amp;sortgroupfield={vb:raw columns.column2}">{vb:raw columns.title2}</a></li></vb:if>
<vb:if condition="$show[field3rd]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column3]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts3}</vb:if>&amp;sortgroupfield={vb:raw columns.column3}">{vb:raw columns.title3}</a></li></vb:if>
<vb:if condition="$show[field4th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column4]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts4}</vb:if>&amp;sortgroupfield={vb:raw columns.column4}">{vb:raw columns.title4}</a></li></vb:if>
<vb:if condition="$show[field5th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column5]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts5}</vb:if>&amp;sortgroupfield={vb:raw columns.column5}">{vb:raw columns.title5}</a></li></vb:if>
<vb:if condition="$show[field6th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column6]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts6}</vb:if>&amp;sortgroupfield={vb:raw columns.column6}">{vb:raw columns.title6}</a></li></vb:if>
<vb:if condition="$show[field7th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column7]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts7}</vb:if>&amp;sortgroupfield={vb:raw columns.column7}">{vb:raw columns.title7}</a></li></vb:if>
<vb:if condition="$show[field8th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column8]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts8}</vb:if>&amp;sortgroupfield={vb:raw columns.column8}">{vb:raw columns.title8}</a></li></vb:if>
<vb:if condition="$show[datejoinedcol]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == 'joindate'">{vb:raw oppositesort}<vb:else />{vb:raw columns.sortsdj}</vb:if>&amp;sortgroupfield=joindate">{vb:rawphrase join_date}</a></li></vb:if>
<vb:if condition="$show[lastactivecol]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == 'lastactive'">{vb:raw oppositesort}<vb:else />{vb:raw columns.sortsla}</vb:if>&amp;sortgroupfield=lastactive">{vb:rawphrase last_activity}</a></li></vb:if>
</ul>
</li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="showroster.php{vb:raw session.sessionurl_q}">Roster</a></li>
</vb:if>
</vb:if>

I'm not saying this is the best way, far from it. I would much rather have had a way to pull the data from my .php to the plugin and then use it in the template that way, but this works for now. I'll gladly accept a better way if someone can tell me. I'm sure I'm added more code than I need.

Okay I am struggling with this. I want to add a button on my navbar that links to a specific forum, and when a user is viewing that forum for the tab on the navbar to be highlighted.

So this is the information that I used:

template name: bb_navbar_events

template code:
<vb:if condition="$vboptions['selectednavtab'] == 'navbarevents'">
<li class="selected">
<a class="navtab" href="forumdisplay.php?8-Events{vb:raw session.sessionurl_q}">{vb:rawphrase navbar_events}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="forumdisplay.php?8-Events{vb:raw session.sessionurl_q}">{vb:rawphrase navbar_events}</a></li>
</vb:if>


plugin code:
if (THIS_SCRIPT == 'xxx') // also defined('navbarevents') possible
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'navbarevents';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('bb_navbar_events')->render();


Should this arrangement be working properly?

I want the Events tab to be highlighted when it is on that page, but the Forum tab remains highlighted.

Any suggestions?

How do you do PERMISSIONS with this? I use the following code for permissions in my mods, and it works fine...

if (!($permissions['medialibperms'] & $vbulletin->bf_ugp_medialibperms['cansubm']))
{
print_no_permission();
}


I am trying to use this code in my plugin, but the permission ALWAYS fails...
if (THIS_SCRIPT == 'media')
{
$vbulletin->options['selectednavtab'] = 'media';

$categories = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "media_category");
$submitperm = $permissions['medialibperms'] & $vbulletin->bf_ugp_medialibperms['cansubm'];

while ($category = $vbulletin->db->fetch_array($categories))
{
$templater = vB_Template::create('media_NAVTAB_cat');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$categorybits .= $templater->render();

$templater = vB_Template::create('media_NAVTAB_sub');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$submitbits .= $templater->render();
}
}

$templater = vB_Template::create('media_NAVTAB');
$templater->register('categorybits', $categorybits);
$templater->register('submitbits', $submitbits);
$templater->register('submitperm', $submitperm);
$template_hook['navtab_middle'] .= $templater->render();

No matter what, $submitperm is always false...

Where do I add these I know to create a new plugin?

Hello,
I am a newbie, please help. Where do I create a template and how am I going to upload to my site.
Second, how do I suppose to "Create a plugin at the hook process_templates_complete" with PHP codes.

I am just really lost and do not know where to begin. Thank you.

im new to this where do create a new templete

Just wanted to say that i used a hybrid between yours and Lynne's walkthrough. I offloaded just the menu items to a template. Thanks for the help ragtek!

http://www.vbulletin.org/forum/showpost.php?p=2163412&postcount=393

Awesome! Thanks for this! Was slightly confused til I tried Lynne's instructions with adding a tab, then I came back to this one and understood (been away from vBulletin for quite awhile)

Hello,

Adapted this to create a link to my main website:

Plugin "Main Website Button", on process_template_complete:

$template_hook['navtab_middle'] .= vB_Template::create('Link to Main Website')->render();

Template "Link to Main Website":

<vb:if condition="$vboptions['selectednavtab'] == 'mainwebsite'">
<li class="selected">
<a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a></li>
</vb:if>

Enjoy!

Exactly what I was looking for. :)

This is a great tutorial! Does anyone know how I can retain the sublinks that show just below the tab bar on the forum tab, across all active tabs?

hi, great tutorial.

little question
my custom page is a clone of content that displays a list of articles on a given section, how can i make those links to point to my page 'news.php' instead of the default 'content.php'?

regards

Is this as easy as adding a Drop down menu, I see those a lot

Hello,

Adapted this to create a link to my main website:

Plugin "Main Website Button", on process_template_complete:

$template_hook['navtab_middle'] .= vB_Template::create('Link to Main Website')->render();

Template "Link to Main Website":

<vb:if condition="$vboptions['selectednavtab'] == 'mainwebsite'">
<li class="selected">
<a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a></li>
</vb:if>

Enjoy!

I tried this but nothing is showing. All I want is a button linking to another website :(:erm:

awesome, works great

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)

<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

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: <vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">

Hi, very new to this so i have to ask, where do you do this?

Everything turns out good.. just have one issue (see screenshot).. I added both tabs, "auction" & "news". When I click news, only the news tab is selected which is what it is supposed to do, however when i select auction, both news & auction are selected..

very strange, any ideas?

Everything turns out good.. just have one issue (see screenshot).. I added both tabs, "auction" & "news". When I click news, only the news tab is selected which is what it is supposed to do, however when i select auction, both news & auction are selected..

very strange, any ideas?
Is this part unique for each?
if (THIS_SCRIPT == 'xxx') // also defined('ragteknews') possible
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'ragteknews';
}

Yes, I have made sure that neither plugins or templates has anything similar, each are using unique templates and plugins.

When I click the "Auction" link both are selected, but when I click "New" only news is selected, so I was thinking that something was wrong with the auction template or plugin, but I can't find anything wrong since it was not unique. Thanks.

Ok, I red the entire thread but didn`t find solution for my problem.

The tab is successfully displayed on my forum navbar, but when I am on the homepage which is CMS I don`t see my new tab, only the default ones: Home, Forum, Blogs, What's New?

Any help ?

Yes, I have made sure that neither plugins or templates has anything similar, each are using unique templates and plugins.

When I click the "Auction" link both are selected, but when I click "New" only news is selected, so I was thinking that something was wrong with the auction template or plugin, but I can't find anything wrong since it was not unique. Thanks.
You'll need to post your code for both so we can see it.

Ok, I red the entire thread but didn`t find solution for my problem.

The tab is successfully displayed on my forum navbar, but when I am on the homepage which is CMS I don`t see my new tab, only the default ones: Home, Forum, Blogs, What's New?

Any help ?
Are you using a different style on the CMS section?

Excellent tutorial!

I have a question about using this with vBa CMPS...I'd like the subnav links to be the various pages of my vBa CMPS. Basically I want the links in the Site Navigation module to show in my navbar.

I've pieced a few things together, but obviously I've done something horribly wrong as they aren't working... :o

I basically just copied and pasted code, so some of this code is not playing well with other parts. I just need to figure out where I need to change things...

Here's my plugin code:
$navigationbits = array();

if (!empty($vbulletin->adv_portal_page))
{
$navpages = array_keys($vbulletin->adv_portal_page);
}

if (!empty($mod_options['portal_navigation_excludepages']))
{
$navpages = array_diff($navpages, $mod_options['portal_navigation_excludepages']);
}

($hook = vBulletinHook::fetch_hook('vba_cmps_module_navigation_start')) ? eval($hook) : false;

if (!empty($navpages))
{
eval('$mod_options[\'portal_navigation_mark1\'] = "' . addslashes($mod_options['portal_navigation_mark1']) . '";');
eval('$mod_options[\'portal_navigation_mark2\'] = "' . addslashes($mod_options['portal_navigation_mark2']) . '";');

foreach ($navpages AS $npageid)
{
$npage =& $vbulletin->adv_portal_page[$npageid];

if (!array_intersect($vbulletin->userinfo['usergrouparray'], $npage['userperms']))
{
continue;
}

if ($npage['level'] <= 1)
{
$navigationbits[$npageid]['navmark'] = $mod_options['portal_navigation_mark1'];
}
else
{
$navigationbits[$npageid]['navmark'] = str_repeat('&nbsp;', (intval($npage['level'] - 1))) . $mod_options['portal_navigation_mark2'];
}

$navigationbits[$npageid]['link'] = $vba_options['portal_homeurl'] . ($npage['name'] != 'home' ? '?' . $vbulletin->session->vars['sessionurl'] . $vba_options['portal_pagevar'] . '=' . $npage['name'] : '');
$navigationbits[$npageid]['title'] = ($npageid == $pages['pageid']) ? '<strong>' . $npage['title'] . '</strong>' : $npage['title'];

($hook = vBulletinHook::fetch_hook('vba_cmps_module_navigation_def_pagebits')) ? eval($hook) : false;
}
}

// Additional pages
$customnavigationbits = array();

if (!empty($mod_options['portal_navigation_addpages']))
{
foreach ($mod_options['portal_navigation_addpages'] AS $key => $navlinks)
{
$customnavigationbits[$key]['title'] = $navlinks['text'];
eval('$customnavigationbits[$key][\'link\'] = "' . addslashes($navlinks['link']) . '";');

if ($navlinks['level'] <= 1)
{
$customnavigationbits[$key]['navmark'] = $mod_options['portal_navigation_mark1'];
}
else
{
$customnavigationbits[$key]['navmark'] = str_repeat('&nbsp;', intval($navlinks['level'] - 1)) . $mod_options['portal_navigation_mark2'];
}

($hook = vBulletinHook::fetch_hook('vba_cmps_module_navigation_cus_pagebits')) ? eval($hook) : false;
}
}

($hook = vBulletinHook::fetch_hook('vba_cmps_module_navigation_end')) ? eval($hook) : false;

$templater = vB_Template::create('portal_navbar');
$templater->register('customnavigationbits', $customnavigationbits);
$templater->register('navigationbits', $navigationbits);
$home["$mods[modid]"]['content'] = $templater->render();


if (THIS_SCRIPT == 'adv_index') // also defined('ragteknews') possible
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'portal';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_start'] .= vB_Template::create('portal_navbar')->render();(with parts taken directly from the navigation.php module code)

and my template code:
<vb:if condition="$vboptions['selectednavtab'] == 'portal'">
<li class="selected">
<a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a>
<ul class="floatcontainer">
<vb:each from="navigationbits" value="page">
<li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
</vb:each>
<vb:each from="customnavigationbits" value="page">
<li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
</vb:each></ul>
</li>
<vb:else />
<li><a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a></li>
</vb:if>(with parts taken from the adv_portal_navigation template)

Where am I going wrong? :)
(I'm obviously NOT a coder...)

the better the more complex ?

Best way possible, please. :)

is this safe? no security holes?

is this safe? no security holes?
The code posted in the first post is perfectly safe. You will need to make sure that all php code that you add yourself has no security holes if you add any.

How can I control the order of the tabs?

How can I control the order of the tabs?

with the template hook names (check template navbar to see all available hooks) and the plugin execution order

I copied and pasted the codes exactly as you have them ragteknews, and I got the tab on there, but it is blank. Also when I click it, it goes to a nonworking page. How can I label the tab "User Photos" and have it go to a gallery of random user photos?

Pitty, but seems that is not working with vB4.2. I'm not getting any error when I'm importing the product file, but there is no Tab in the bar.

Chris

Anyone know how to make this work in 4.2?

4.2.1 has a Navigation Manager to do this without using this article.

Can user this for auto add tabs when write plugin?










privacy (GDPR)