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

Here's a pretty simple method for creating a new tab in the navbar, along with a submenu to go along with it. All you need is a unique condition for when your tab will be shown. What you will be making is a plugin to create the Nav Link along with a submenu which Link 1, Link 2, Link 3, and Drop Down which then drops down and has SubLink 1, SubLink 2, and SubLink 3. This is shown below.

NOTE: This is for 4.0.x and 4.1.x. In 4.2.x, you should be using the Navigation Manager.

https://www.vbulletin.org/forum/external/2011/07/104.jpg


This article is NOT to be used just to add another link to a submenu. It is for creating the Nav Link tab along with all the submenus. Again, if all you want is to add submenus to an existing tab, then this article is NOT for you!!!

This article is also for use by users who understand the basics of conditions and can write them. The navbar is not really an easy thing to play with if you don't know what you are doing - I think even Wayne said it had issues - so don't try this if you don't understand how to write a condition.

OK, with that out of the way....

Here's the basic template for making your new tab:

Create a plugin (Plugins & Products) > Add New Plugin:
hook location - process_templates_complete *
Title - New Tab for Navbar
Execution Order - 5
(* I used to have this listed as global_state_check but then noticed vb themselves use the process_templates_complete hook location, so I changed it.)


$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'yourpage')
{
$vbulletin->options['selectednavtab']='unique_name';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;
Things to take note of:

if (THIS_SCRIPT == 'yourpage')Your condition MUST be unique! If you use a condition that is also going to evaluate to true for another tab, then they will both be highlighted and the wrong submenu may show up underneath.

$vbulletin->options['selectednavtab']='unique_name';The 'seletednavtab' must also be a unique name. Again, if you have two tabs with the same 'selectednavtab' name, then both tabs will be highlighted.

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;You may use a different template_hook here - it just depends on where you want your tab to be - navtab_start and navtab_middle are also available.


ragtek also posted an article to do the same thing only using a template with the plugin - [HOW TO - vB4] Create a New Tab in the navbar (with template) (http://www.vbulletin.org/forum/showthread.php?t=228313)



Originally posted on vb.org 2009-10-27.

Other related articles of possible interest:
[HOW TO - vB4] Remove the vB Default Navtabs (http://www.vbulletin.org/forum/showthread.php?t=234220)
[HOW TO - vB4] Create your own vBulletin page (http://www.vbulletin.org/forum/showthread.php?t=228112)

Thanks, Lynne! Good work, will come in handy!

What are we suppose to type in for THIS_SCRIPT? I tried "index".

I made link.php to read as index.php.

What specifically are we suppose to put in for "unique_name"? Can we type anything like rabbit or dog?

When I click on the forum logo the newly created Nav Link shows up with its menu and submenu now instead of the forum.php Forum tab and its menu.

But when I click back on the Forum tab it does not highlight nor do its menu show up, but the newly created Nav Link with its menu remains highlighted.

It gets even stranger. When I click on the Home tab it works, but then try to click back on the Nav Link it doesn't let me.

And when I am in the Nav Link and click on the Nav Link it sends me to Home Tab with its menu.

Help.

Hi Lynne,
I've copied the whole code and only changed link.php to another page, but it still does not 'select' itself on the navbar. I tried with a few unique names and such. No go. Here's the code I've tried.

global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'eventslink1')
{
$vbulletin->options['selectednavtab']='eventslink2';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="calendar.php">Calendar</a>'.$tablinks.'</li>' ; Thanks again for all your help lately. Don't know what VB would do without ya :p

What are we suppose to type in for THIS_SCRIPT? I tried "index".

I made link.php to read as index.php.

What specifically are we suppose to put in for "unique_name"? Can we type anything like rabbit or dog?

When I click on the forum logo the newly created Nav link shows up with its menu and submenu now instead of the forum.php forum tab and its menu.

But when I click back on the forums tab it does not highlight nor do its menu show up, but the newly created Nav bar link with its menus remain highlighted.

Help.
What is your goal here? When do you want this tab to be active? You want it active when a user is on the forum.php page (that one is defined as "index")? That will be a bit weird since you click the Forum tab and it goes to forum.php but you aren't going to have the Forum tab highlighted this way because the "index" page also the same as the the main entry page for you when the Forums link comes up active? If so, that condition may be a bit weird in which case you may want to change it to be something a bit more unique. So, first we need to define when you want that tab to be Active.

Hi Lynne,
I've copied the whole code and only changed link.php to another page, but it still does not 'select' itself on the navbar. I tried with a few unique names and such. No go. Here's the code I've tried.

global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'eventslink1')
{
$vbulletin->options['selectednavtab']='eventslink2';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="calendar.php">Calendar</a>'.$tablinks.'</li>' ; Thanks again for all your help lately. Don't know what VB would do without ya :p
Same with you.... went do you want this tab to be Active? That is the condition you need to write. Most people want it active when they are on a specific page. At the top of that vbulletin page, THIS-SCRIPT is defined like this:
define('THIS_SCRIPT', 'a_page_name');In this case, your condition would be:
if (THIS_SCRIPT == 'a_page_name')The condition does NOT have to be based on THIS_SCRIPT, but it DOES have to be UNIQUE to that tab.

Lynne,

Tell us what to type in for "yourpage", "unique_name", "link.php" so it works like a tab is suppose to work.

When I click on my logo I want the Forum tab to start up as it does from the install of 4.0 and not go immediately to the Nav Link. Then I want to go to my Nav Link tab when I click on it with its menu without getting jumped around and without any of the above mentioned problems.

What do you want on your navbar? Why are you adding a new tab? I can't tell you what to put there if I have no clue what it is for.

Right now, if you have 'index' in for 'yourpage' then yes, if you click on Forums it will highlight your new tab instead because your condition is true (you are on the forum.php page which is defined as THIS_SCRIPT == index). When do you want the Nav Link to be highlighted? It will be highlighted when $vbulletin->options['selectednavtab']='unique_name' and $vbulletin->options['selectednavtab']='unique_name' when THIS_SCRIPT == "yourpage".

I just want the Nav Link to work like you would expect it to work and with its menus of various external and internal links like I had with 3.8.4. Tell me what to fill in for "yourpage", "unique_name", "link.php" to able to make that happen.

Very useful indeed. Thank you.

I just want the Nav Link to work like you would expect it to work and with its menus of various external and internal links like I had with 3.8.4. Tell me what to fill in for "yourpage", "unique_name", "link.php" to able to make that happen.
yourpage would be what THIS_SCRIPT is defined as at the top of the page you click on to make the navtab active

unique_name is any unique word

link.php is the page you wish the user to go to when they click the tab

I think what you are saying is that using that set of code you can't get the Nav Link with menus and submenues to work like I had it working with 3.8.4. I'll wait till someone figures something out.

I don't know if you can. I have no idea what you had working - you've supplied no details whatsoever on it (no details, no images, no anything).

I don't know if you can. I have no idea what you had working - you've supplied no details whatsoever on it (no details, no images, no anything).
In post #6 I said, "When I click on my logo I want the Forum tab to start up as it does from the install of 4.0 and not go immediately to the Nav Link. Then I want to go to my Nav Link tab when I click on it with its menu without getting jumped around and without any of the above mentioned problems."

Basically, just like you would expect any link to work, with sublinks and drop down box, like the other tabs work. Pretty simple: able to put in whatever links I want.

I have a feeling before 4.0 Gold comes out, they will provide this as an automated feature. It's a no brainer.

In post #6 I said, "When I click on my logo I want the Forum tab to start up as it does from the install of 4.0 and not go immediately to the Nav Link. Then I want to go to my Nav Link tab when I click on it with its menu without getting jumped around and without any of the above mentioned problems."

Basically, just like you would expect any link to work with sublinks and drop down box like the other tabs work. Pretty simple.
And what is the link that your logo goes to? I have no clue. So, I can't suggest what to put in place of link.php, since you have't posted the link. I also can't suggest what to use for 'yourpage' since I don't know what page it is. I need *details*. If I only get general information from you, I can only give you general information back.

By clicking on the logo the basic navbar takes one to the forums page and highlights the forum tab. That's what I want, obviously. I don't want that to change. I don't want the Nav Link to be highlighted when I click on the logo which was happening with 'yourpage' as 'index' and 'link.php' as 'index.php'. I want to be able to add some external links and some internal links to the menu of Nav Link. I have no idea what to name 'yourpage' and 'link.php' for the Nav Link to work like any normal functioning tab with a drop down menu. When I click on the other existing tabs I don't want the Nav Link tab to be highlighted as the case is now. I don't want to get jumped to the Home tab by clicking on the Nav Link. By clicking on the Nav Link I want the menu to show up for the Nav Link. I want all existing tabs to work as they normally do and not be interferred with by the Nav Link, e.g. by clicking on the Forum tab, the Nav Link tab is highlighted with its menu.

Basically I want it to work like any link would work with its menu. Pretty simple. I just don't know what to put in for values for 'yourpage' and 'link.php' to make this happen or if it is even possible. For example, on your own site what would you put in for these values to make it work which I could try out also to see if it works for me too?

If it doesn't work then it doesn't work. Need to try something else: rewrite the code.

There's also a other way adding own tabs: http://vbcodex.com/showthread.php?665-Adding-own-Links-Tabs-to-the-vB4-Navbar

Basically I want it to work like any link would work with its menu. Pretty simple. I just don't know what to put in for values for 'yourpage' and 'link.php' to make this happen or if it is even possible. For example, on your own site what would you put in for these values to make it work which I could try out also to see if it works for me too?

If it doesn't work then it doesn't work. Need to try something else: rewrite the code.

OK, I'll give you an example of what I did on my site and maybe it will help you figure out what you really want..

I have torrents offered on my site. I have a torrents.php page, and few forums for the torrents and some upload pages and stuff. So, I want to link to that page - torrents.php. So, I have "link.php" set to "torrents.php". And, I have THIS_SCRIPT defined as "TORRENTS" at the top of the torrents.php page. Since I also want it to show that link when they are in the two torrents forums, I included that in the condition also. So, I used this as my unique condition:
if (THIS_SCRIPT == 'TORRENTS' OR in_array($GLOBALS['forumid'], array(x, y, z)))As for my "unique_name", I just used "torrents".

This is the result on my site:
106152



If all you want to do is add a link to one of the existing sub-menus (like before New Posts in the Forum tab), then you can either just modify the navbar directly or use an existing template_hook (in the example of before New Posts, then the "navbar_start" template_hook) just like you did in vb3. This tutorial is for adding a whole new tab with a sub-menu.

Thank you Lynne. As usual, your tutorial makes it easier to relearn vb

Seems like a lot of work just to add two or or three new links but o.k.. I think I can do this.

--------------- Added 1258476269 at 1258476269 ---------------

o.k.. I'm stumped. Sorry...

Does this article help me create more drop down tabs or more links horizontally across the navbar? For example my beta site navbar says - Home Page New Products News Events

All I want to do is add about 5 more links to the right of that. When I created some sections the names of the sections appeared in the navbar by themselves. The new sections I created don't. Is there some setting I can just change the qty of links to show and they will appear?

I'm new to tweaking my forum so I'm sorry if this is a really stupid question.

--------------- Added 1258476853 at 1258476853 ---------------

Oh, I see what I did. I just renamed a few sections. In the link it still calls the old name. Example, my new products section used to be called travel.

I really don't know what you are asking about or what you want. This article is about how to add a new tab - like Home, Forums, What's New?, Blogs - and the little sub-sections below them. If all you want to do is add to the sub-section menu, then you would just use a template_hook.

Please visit http://www.pro-touring.com/forum_new/content.php?1-the-front-page

In the upper left on the navbar it says

* Home Page * New Products * News * Events

To the right of events I want to add *Tech of the week *Member of the month * Advertise with us

or something like that.

Please visit http://www.pro-touring.com/forum_new/content.php?1-the-front-page

In the upper left on the navbar it says

* Home Page * New Products * News * Events

To the right of events I want to add *Tech of the week *Member of the month * Advertise with us

or something like that.
Then this is not the article for you. This article would help you add a whole new tab next to What's New. The sections in the CMS are added through the Section Manager. Don wrote an article (or blog, I forget) on how to do this over on vb.com

Hmm, I am able to add sections. I have 6 or 8 of them and I added them through the control panel but they don't show at the top. Thanks! I will head over.

How do I show links forum categories navbar? Same as forum blog cms

How do I show links forum categories navbar? Same as forum blog cms
I don't understand what you mean.

Lynne,

How do you add them for a certain usergroup?

Basically what I want to do is add a linked drop down for private members linking to various sections that only the private members can see, things like arcade.php, gameroom.php etc etc.

Is it...

global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'yourpage')
{
$vbulletin->options['selectednavtab']='private_members';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="URL LINK">Prediction League</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="arcade.php">Arcade</a></li>
<li><a href="gameroom.php">Gameroom</a></li>
<li><a href="THE LINK TO FORUM">Forum</a></li>
</ul>
</li>
<li><a href="URL LINK">Gallery</a></li>

</ul> ';

}



I also want to link to external links, can I do this or am I better doing it via the bottom code
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;

Thanks:confused:

Please www.arenatr.com (http://www.arenatr.com) look top navbar link (Forum categories)

Lynne,

How do you add them for a certain usergroup?

Basically what I want to do is add a linked drop down for private members linking to various sections that only the private members can see, things like arcade.php, gameroom.php etc etc.

Is it...

global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'yourpage')
{
$vbulletin->options['selectednavtab']='private_members';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="URL LINK">Prediction League</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="arcade.php">Arcade</a></li>
<li><a href="gameroom.php">Gameroom</a></li>
<li><a href="THE LINK TO FORUM">Forum</a></li>
</ul>
</li>
<li><a href="URL LINK">Gallery</a></li>

</ul> ';

}

I also want to link to external links, can I do this or am I better doing it via the bottom code
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;Thanks:confused:
If you want to add in a condition, you could do something like this for say, arcade.php to only usergroup 5,6, ad 7:
$tablinks = '<ul class="floatcontainer">
<li><a href="URL LINK">Prediction League</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">';
if (is_member_of($vbulletin->userinfo, 5, 6, 7))
{
$tablinks .= '<li><a href="arcade.php">Arcade</a></li>';
}

$tablinks .= ' <li><a href="gameroom.php">Gameroom</a></li>
<li><a href="THE LINK TO FORUM">Forum</a></li>
</ul>
</li>
<li><a href="URL LINK">Gallery</a></li>

</ul> ';
That isn't tested, but it should work. And, there is no reason you can't make external links.

Please www.arenatr.com (http://www.arenatr.com) look top navbar link (Forum categories)
Sorry, but I still don't understand your question. That is not a vb4 site at all.

If you want to add in a condition, you could do something like this for say, arcade.php to only usergroup 5,6, ad 7:
$tablinks = '<ul class="floatcontainer">
<li><a href="URL LINK">Prediction League</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">';
if (is_member_of($vbulletin->userinfo, 5, 6, 7))
{
$tablinks .= '<li><a href="arcade.php">Arcade</a></li>';
}

$tablinks .= ' <li><a href="gameroom.php">Gameroom</a></li>
<li><a href="THE LINK TO FORUM">Forum</a></li>
</ul>
</li>
<li><a href="URL LINK">Gallery</a></li>

</ul> ';
That isn't tested, but it should work. And, there is no reason you can't make external links.


Sorry, but I still don't understand your question. That is not a vb4 site at all.

Thank you very much lynne, am at a loss thou with the


if (THIS_SCRIPT == 'yourpage')


Where do you get that from?

When you create your own page (http://www.vbulletin.org/forum/showthread.php?t=228112), you have to define this_script;)

Right... think i've sussed it,

I put in index which displayed it :) BUT.....

the rest of the links that were already there disappeared :(

anyway of keeping them and adding the drop down at the end of

* New Posts
* Private Messages
* FAQ
* Calendar
* Community
* Forum Actions
* Quick Links

thank you thou lynne :up:

Sorry, but where do i add this code to?

Thanks :)

Sorry, but where do i add this code to?

Thanks :)

+1 here, do we just throw it in the navbar template then:confused:

OK, I'll give you an example of what I did on my site and maybe it will help you figure out what you really want..

I have torrents offered on my site. I have a torrents.php page, and few forums for the torrents and some upload pages and stuff. So, I want to link to that page - torrents.php. So, I have "link.php" set to "torrents.php". And, I have THIS_SCRIPT defined as "TORRENTS" at the top of the torrents.php page. Since I also want it to show that link when they are in the two torrents forums, I included that in the condition also. So, I used this as my unique condition:
if (THIS_SCRIPT == 'TORRENTS' OR in_array($GLOBALS['forumid'], array(x, y, z)))As for my "unique_name", I just used "torrents".

Is it possible to add a unique condition to a Section page? or barring that is there a way to use the page title, section title or SEO URL Alias perhaps? (sorry if this is obvious - I am new to php) I would like to have a section named "Marketplace" for information on my classifieds program. It's an important part of my site so needs to be more visable, plus I want to add external links to my classifieds pages for easier navigation.

I successfully created my new tab and named it Marketplace
link.php is set to "http://www.mydomain.com/content.php?2-Marketplace"
unique_name is Marketplace

Sorry, but where do i add this code to?

Thanks :)

I think you must place the code into the plugin system at global_state_check , but I could be mistaken, truthfully I am a bit lost on this one lol

Lynne states where the code has to go - into a plugin at:
hook location - global_state_check

Don't know how she could make that clearer ;)

Right... think i've sussed it,

I put in index which displayed it :) BUT.....

the rest of the links that were already there disappeared :(

anyway of keeping them and adding the drop down at the end of

* New Posts
* Private Messages
* FAQ
* Calendar
* Community
* Forum Actions
* Quick Links

thank you thou lynne :up:
If you want to just add to the submenu list that is there, then this is NOT the article for you. This article tells you how to add a whole TAB and then submenu links under it. If all you want is to add to the existing submenu, then I am pretty sure there are template_hooks to use.
Sorry, but where do i add this code to?

Thanks :)
It goes into a plugin, as I said in my post. However, read what I wrote above... this article shows you how to add an entire tab - it isn't used to just add to an existing tab.
Is it possible to add a unique condition to a Section page? or barring that is there a way to use the page title, section title or SEO URL Alias perhaps? (sorry if this is obvious - I am new to php) I would like to have a section named "Marketplace" for information on my classifieds program. It's an important part of my site so needs to be more visable, plus I want to add external links to my classifieds pages for easier navigation.

I successfully created my new tab and named it Marketplace
link.php is set to "http://www.mydomain.com/content.php?2-Marketplace"
unique_name is Marketplace
I haven't tried many other conditions with this. If you want to do it for a Section, then you would also have to modify the existing navbar to not show the Home tab when you are on that section, otherwise it isn't unique. Right now, the Home tab shows whenever you are in the CMS area of the site. So, you'd have to change that condition to say "in the CMS but NOT in section xx" otherwise both tabs will be highlighted and only one of the submenus will be shown. I'm not sure what the exact condition would be since I'm not that familiar with all the variable names used with the new CMS ($sectionid == 2 ?).

Thanks Lynne,
http://www.bizimforumlar.com/vbtest/test.php

Lynne states where the code has to go - into a plugin at:


Don't know how she could make that clearer ;)

Sure, if you understand it all to the level that Lynne does then that might be 'very' clear, but to persons like myself it meant absolutely nothing to me. Had we been directed to the plugin manager as a clear and helpful guide for the not so knowledgeable in vbulletin coding would have then we wouldn't have to ask such boring question would we. Seriously, I get sick to death of that sort of tone, why couldn't you have directed us to the plugin manager instead of giving us your sarcasm.

You do know what a smiliey is and means, do you? Now, if I wanted to be ironic or sarcastic about something, I'd point you to the Wikipedia article on emoticons. But I don't, however hard you try to misunderstand me :)

I added a bit more to the first post including the part about going to the Plugin Manager. However, this article really isn't for the total novice. You need to understand what a condition is and be able to write one.

I looked but did not find the answer. How do you add a phrase in this code for Sublink 1?

<li><a href="sublink1.php">SubLink 1</a></li>

I tried ' . $vbphrase['my_phrase'] .'
I tried {vb:rawphrase my_phrase}

never mind ... I needed to globalize it

What ever level we understand coding Lynne should not matter, I accept my understanding of coding needs improvement, but that's not the point. We are trying to get our heads around vB4, which is no walk in the park and we look to people like yourself for help. You do a fantastic amount of good here and I personally truly appreciate that, but clear and straight forward guides help more than being told we lack understanding.

To cellarius, I apologise, I find myself enduring a great deal of keyboard warriors here and there and I mistook your post as yet another jibe from another coward hiding behind a keyboard. Didn't mean to be offensive and I am sorry for offending you.

Neither did I want to mock you or anything, sorry for perhaps coming off like that - so, we're good here :)

Anyway, I really see where you are coming from, I learned a lot from tutorials like this very one. I understand what you mean, but it is always about finding a middle way in texts like this. There's some basics you need to build upon if you want to do some in-depth explaining, or the tutorials would get overly complex. There's other articles about the plugin system, and even a section in the manual. If one had to explain that every time again, the articles would be cluttered. Finding this middle way is not always easy, tho, and you won't be able to need everyones needs :o

How can we change the display order of the navbar. Meaning put new items(per this tutorial), so that they show between "blogs" and "whats new"

How can we change the display order of the navbar. Meaning put new items(per this tutorial), so that they show between "blogs" and "whats new"
There are currently three template_hooks available for adding the tabs (I listed them in the first post). If none of those are located where you want them, then you can just add one into the template where you want it. That will require editing the template though.

Lynne,

Thanks for this awesome guide. So I'm trying to hide the tab from people not logged in. Also I only want some user groups to see it. This is what I have so far.

global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Buy Now')
if (is_member_of($vbulletin->userinfo, 5, 6, 7))
{
$vbulletin->options['selectednavtab']='Buying';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://mysite.com/forum/showthread.php?1-testpost">Buy Now</a>'.$tablinks.'</li>' ;

I tried just testing out the if statement first to see if I could only let some user groups see the tab. But that didn't work. Maybe I placed it in the wrong place?

--------------- Added 1258564039 at 1258564039 ---------------

Woot I just fixed it. I put the if statement above the global and it works. Doesn't matter about the member part now. Because if they are not part of the right group it won't even show up. :-)

So here is my answer:
if (is_member_of($vbulletin->userinfo, 5, 6, 7))
global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Buy Now')
{
$vbulletin->options['selectednavtab']='Buying';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://mysite.com/forum/showthread.php?1-testpost">Buy Now</a>'.$tablinks.'</li>' ;

You really should have { and } around the whole thing after your if is_member_of statement. Right now, you are basically just saying if is_member_of then make the $template_hook global, which is needed right now for this plugin to work. If they fix the issue of the $template_hook not being global, then suddenly your plugin isn't going to work because it will be made global elsewhere and therefore work.

Ok so something like this?

if (is_member_of($vbulletin->userinfo, 5, 6, 7))
{
global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Buy Now')
{
$vbulletin->options['selectednavtab']='Buying';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://mysite.com/forum/showthread.php?1-testpost">Buy Now</a>'.$tablinks.'</li>' ;
}

Oh this is the Kallell account by the way :-) With your help we found out how to set up more than one account with access.

Yes, that looks correct - you have the content of the whole plugin in the condition now.

Hello Kallell! Now I recognize you. :)

Yes, that looks correct - you have the content of the whole plugin in the condition now.

Hello Kallell! Now I recognize you. :)

:)

What about if I want to add two tabs? with one unblocked and the other one set to usergroups. Would it be like this:

if (is_member_of($vbulletin->userinfo, 5, 6, 7))
global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Buy Now')
{
$vbulletin->options['selectednavtab']='Buying';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="HTTP LINK or PHP file">Link Name</a>'.$tablinks.'</li>' ;
if (is_member_of($vbulletin->userinfo, 5, 6, 7))
if (THIS_SCRIPT == 'Download')
{
$vbulletin->options['selectednavtab']='Name';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Test Name</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="HTTP LINK or PHP file">Link Name</a>'.$tablinks.'</li>' ;

:)

What about if I want to add two tabs? with one unblocked and the other one set to usergroups. Would it be like this:



You would copy the plugin and put one after the other, like you did, however just don't wrap the unblocked one with the is_member_of condition AND call $tablinks and $tablselected something different in the second one - like $tablinks2 and $tabselected2.

I haven't tried many other conditions with this. If you want to do it for a Section, then you would also have to modify the existing navbar to not show the Home tab when you are on that section, otherwise it isn't unique. Right now, the Home tab shows whenever you are in the CMS area of the site. So, you'd have to change that condition to say "in the CMS but NOT in section xx" otherwise both tabs will be highlighted and only one of the submenus will be shown. I'm not sure what the exact condition would be since I'm not that familiar with all the variable names used with the new CMS ($sectionid == 2 ?).

how to find the variable name listing for the CMS? i'm looking anywhere and found nothing. i'm temporary disabling the highlight effect for Home and New Page navigation.

-edit-
i've just removed #navtabs li.selected a.navtab from vbulletin-chrome.css, the navigation structure doesn't make sense. when vbull combined with CMS, features such as calendar, FAQ, photo gallery, friends, group should be global and not under the forum section. they should have it's own link at the parent navigation bar. now i will just manually add navigation links from the template, hope vbull developer will fix this in the future.

Hello all! I am puzzled. I tried to adopt this with the following code to link to our store on our site.


$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'STORE')
{
$vbulletin->options['selectednavtab']='STORE_tab';
$tabselected = ' class="selected"';
$tablinks = '
<ul class="floatcontainer">
<li><a href="https://www.scsimulations.com/store/">Store</a></li>
</ul>
';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="https://www.scsimulations.com/store/">Store</a>'.$tablinks.'</li>' ;


The above doesn't seem to do a thing.

Any help? (I'm not the best in PHP coding...so I appreciate a layman's explaination if possible.)

Is "https://www.scsimulations.com/store/" this a page your wrote yourself? Does it have a line at the top that defines THIS_SCRIPT as STORE like this?
define('THIS_SCRIPT', 'STORE');
When you say it doesn't seem to do anything, are you seeing a tab at all? Do you have the plugin active?

It sure is....and it wasn't activated...:eek:

Its always the simplest solution.

Appreciate it!

First off, great article it's really helped me in getting my test site going. Is there a way that anyone knows of to have a specific navtab show as selected if a certain article is showing. Basically I guess what i'd need to do is set what the script id is for a specific article. Any ideas?

I am not familiar enough with the new cms to know the answer to that question. You would, however, have to actually do some modifying to some code somewhere since the condition is already set that if you are in the cms, then the Home tab is selected. So, you'd have to change that code to say "if in cms except this article, then the Home tab is selected".

Lynne, I have thehack working but would love to have a sub link on the sub link as you have tab saying Tech with a link saying Carburetors then you have Cleaning Carbs and Jetting. so you would have
Tech>Carbs>cleaning Carbs
and
Tech>Carbs>Jeting
Menu would look like
Carbs
Cleaning
Jetting
What would code be?

Lynne, I have thehack working but would love to have a sub link on the sub link as you have tab saying Tech with a link saying Carburetors then you have Cleaning Carbs and Jetting. so you would have
Tech>Carbs>cleaning Carbs
and
Tech>Carbs>Jeting
Menu would look like
Carbs
Cleaning
Jetting
What would code be?
I'm not sure I follow you. The article covers how to get submenus. What is your exact plugin, and what is the result and what do you want changed (images would help).

Thanks for the quick reply... Great article. In the attachment you can see that I have it working. What I am looking to do is add a sub menu to the sub menu. I have the Tech Area tab then the sub menu that has Carbs trying to add a sub menu to carbs so it will have Cleaning link and Jetting link. So basically making when you click on carbs it does not take you to Carbs.php but opens a sub menu that would have links to jetting.php and Cleaning.php

Thanks
Eric

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Tech')
{
$vbulletin->options['selectednavtab']='Tech Area';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Vmax-4 750</a>
<ul class="popupbody popuphover">
<li><a href="Carbs.php">Carbs</a></li>
<li><a href="Clutch750.php">Clutching & Gearing</a></li>
<li><a href="Pipes750.php">Pipes</a></li>
<li><a href="Track.php">Track</a></li>
<li><a href="Setup750.php">Setups</a></li>
</ul>
</li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Vmax-4 800</a>
<ul class="popupbody popuphover">
<li><a href="Carbs.php">Carbs</a></li>
<li><a href="Clutch800.php">Clutching & Gearing</a></li>
<li><a href="Pipes800.php">Pipes</a></li>
<li><a href="Track.php">Track</a></li>
<li><a href="Setup800.php">Setups</a></li>
</ul>
</li>
<li><a href="Specs.php">Stock Specs</a></li>
</ul> ';

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

I don't know how to add a submenu to a submenu as I haven't tried to do that. You'll have to play with the css to do that.

Is there any way to use vb if statements with this mod?

I tried wrapping certain links under the custom tab in the


<vb:if condition="$show['modcplink']">
*stuff here*
</vb:if>

(I only wish admins/mods to be able to see a certain link)

but it completely breaks this plugin, you get a

Parse error: syntax error, unexpected T_STRING in /home/anseur/public_html/vb4test/includes/class_bootstrap.php(386) : eval()'d code on line 23


message from vb at the top of the custom page.

Does perhaps some other function have to be called in either this or the .php page in question? (I'm using the custom php page Lynne posted an article on in conjunction with this plugin)

the same vb if statement works if I put it elsewhere within a template that apears on the page, but I would like the link in question to be in the navbar and not in the body.

This post shows how to use conditions to add the links - http://www.vbulletin.org/forum/showpost.php?p=1916136&postcount=28 See if that helps.

I actualy tried that way of doing it too, what happens if with is, the if conditional just gets put in the navbar as plain text, as if vb is not seeing it as a conditional. I notice the syntax highlighting on the plug code input page also doesn't color the extra if statement in green like the if statement at the top for the 'this_script ==' one.

Here's my complete code for the navtab plugin:


$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'dkp.php')
{
$vbulletin->options['selectednavtab']='dkp_listmembers';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">



<li class="popupmenu">
<a href="javascript://" class="popupctrl">Administration</a>
<ul class="popupbody popuphover">
if (is_member_of($vbulletin->userinfo, 5, 6, 13, 14))
{
<li><a href="/25manwrathplus/admin/" target=dkp_frame>Eqdkp Admin Index</a></li>
<li><a href="/25manwrathplus/plugins/ctrt/" target=dkp_frame>Import CTRA String</a></li>
<li><a href="/25manwrathplus/admin/addiadj.php" target=dkp_frame>Do Adjustments</a></li>
}

</ul>
</li>


<li><a href="/25manwrathplus/listmembers.php?s="
target=dkp_frame>Standings</a></li>
<li><a href="/25manwrathplus/listraids.php?s="
target=dkp_frame>Raids</a></li>
<li><a href="/25manwrathplus/listevents.php?s="
target=dkp_frame>Events</a></li>
<li><a href="/25manwrathplus/listitems.php?s="
target=dkp_frame>items</a></li>
<li><a href="/25manwrathplus/listitems.php?s=&p=history"
target=dkp_frame>History</a></li>
<li><a href="/25manwrathplus/stats.php?s="
target=dkp_frame>Stats</a></li>
<li><a href="/25manwrathplus/plugins/raidplan/listraids.php?s="
target=dkp_frame>Raid Planner</a></li>
<li><a href="/25manwrathplus/plugins/raidplan/raidstats.php?s="
target=dkp_frame>Raid Planner Stats</a></li>


<li class="popupmenu">
<a href="javascript://" class="popupctrl">Your DKP Account</a>
<ul class="popupbody popuphover">

<li><a href="/25manwrathplus/settings.php?mode=account" target=dkp_frame>Account Settings</a></li>
<li><a href="/25manwrathplus/plugins/raidplan/usersettings.php" target=dkp_frame>Raid Planner Settings</a></li>
<li><a href="/25manwrathplus/login.php?logout=true" target=dkp_frame>Log Out of Eqdkp</a></li>
<li><a href="/25manwrathplus/login.php" target=dkp_frame>Log Into Eqdkp</a></li>

</ul>
</li>

</ul> ';


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


I tried putting the conditional before the first <li> on the top most popup control, before the <a> just below it, and where you see it now. (with the bracket closed in the appropriate place in each instance. same thing happens on each occasion.

Only difference I can see in the example you gave and my version, is I'm trying to hide an entire popup control to non admins, your example just tries to hide a link.

I'd suggest you start over with the plugin because you've totally messed up the structure of the submenu.

The reason why you are ending up with the condition showing up in the code is because you are putting it there. Look again at the code I wrote. You need to *end* your writing to the variable $tablinks, then do the condition and add to $tablinks if the condition is true, and then continue writing to it later on. But, you need to break out of writing to it in order to do the condition - you just put the condition right in the middle of it! Basically:
$tablinks = 'a bunch of stuff';
if (is_member_of($vbulletin->userinfo, 5, 6, 13, 14))
{
$tablinks .= 'more stuff if condition is true';
}
$tablinks .= 'and more stuff';

I'd suggest you start over with the plugin because you've totally messed up the structure of the submenu.

Nah, no need. It's not 'messed up' it's layout is exactly how I intend it to look, with multiple drop downs etc. It works perfectly without the condition in it.

But, you need to break out of writing to it in order to do the condition - you just put the condition right in the middle of it! Basically:
$tablinks = 'a bunch of stuff';
if (is_member_of($vbulletin->userinfo, 5, 6, 13, 14))
{
$tablinks .= 'more stuff if condition is true';
}
$tablinks .= 'and more stuff';

From this example I understand. I'm not really a coder so I didn't understand what the $tablinks did, now with that example, I do.

Thanks again.

Nah, no need. It's not 'messed up' it's layout is exactly how I intent it to look, with multiple drop downs etc. It works perfectly without the condition in it.
Maybe I did something weird on my end, but when I tried it, it did some wacky things.

I did everything you said in the first post, and it works perfectly. There is only one thing I can't figure out.

If I click the links below the button, link1.php for example, it doesn't keep that button selected. It highlights the forum button again.

Is there anyway I can put multiple "yourpage" names in that code so it keeps the button highlighted even when going to a page by clicking a link below the button?

if (THIS_SCRIPT == 'yourpage')

--------------- Added 1259795597 at 1259795597 ---------------

NVM fixed it

I fixed the first issue I had, but I have another question. In my images you can see what I mean.

I want the second image, the affiliate one, to show home in front of it as well. Just like in the first image. How can I change that?

Like it says: Home > Frontpage

And the other one only says: Affiliates

I fixed the first issue I had, but I have another question. In my images you can see what I mean.

I want the second image, the affiliate one, to show home in front of it as well. Just like in the first image. How can I change that?

Like it says: Home > Frontpage

And the other one only says: Affiliates
That has nothing to do with this article - you are asking about the navbits code. You should ask for help modifying that code out in the main vb4 forums. (And actually, I believe it is a problem with your affiliates page and the way your wrote the navbits code, so you should post that part of your code when you ask for help.)

I made a new thread about this. If you can help me please go here:
http://www.vbulletin.org/forum/showthread.php?p=1924354#post1924354

Okay, so I was able to add a link to the navbar with this tutorial. But when I click on the link I just got white page and not the result you have in the screenshot. I tried to add link.php from your other tutorial (http://www.vbulletin.org/forum/showthread.php?t=228112), but it didn't change anything. What am I doing wrong? Sorry for the noob question (:

Edit: Aah, nevermind. In the link.php I was using caps for the template name like in the test.php. Didn't realize it was the template name I created until now that I rechecked the code.

This sounds like a problem from your custom page, not this tutorial. You should ask questions about the custom page in the other article, not here (it gets confusing if you mix up articles and problems).

Do you have to create your own vBulletin page to use this? I created a section and am trying to use this tutorial to go to that section, yet I can't get the navbar to highlight. Here is the code as I have it now (I removed the submenu link code):

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'podcast')
{
$vbulletin->options['selectednavtab']='podcast';
$tabselected = ' class="selected"';
$tablinks = '
<ul class="floatcontainer">

</ul> ';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="/forums/content/116-podcast">Podcast</a>'.$tablinks.'</li>' ;

No, you do not need to create your own vB page to use it. Right now, your code shows that your tab should be selected when you are on a page where THIS_SCRIPT is defined as podcast. Perhaps you meant to use something like this instead?
if ($_REQUEST['do'] == 'podcast')

No, you do not need to create your own vB page to use it. Right now, your code shows that your tab should be selected when you are on a page where THIS_SCRIPT is defined as podcast. Perhaps you meant to use something like this instead?
if ($_REQUEST['do'] == 'podcast')

So I should replace

if (THIS_SCRIPT == 'podcast')

with

if ($_REQUEST['do'] == 'podcast'

I tried this but get a PARSE error.

Maybe that's where I'm getting confused. How do you define a page as something like 'podcast'?

If you replaced it with exactly what you wrote, then yes, you will get a parse error because you are missing the end parenthesis.

At the top of each vb page is something like this:
define('THIS_SCRIPT', 'online');

That defines the page name. So, if you are going to have the tab highlight because you are on a specific page, that is the best method to use. But, you can use other valid conditions also as long as they don't interfere with the conditions to have another tab highlighted.

If you replaced it with exactly what you wrote, then yes, you will get a parse error because you are missing the end parenthesis.

At the top of each vb page is something like this:
define('THIS_SCRIPT', 'online');

That defines the page name. So, if you are going to have the tab highlight because you are on a specific page, that is the best method to use. But, you can use other valid conditions also as long as they don't interfere with the conditions to have another tab highlighted.

Maybe I wasn't clear. Where do I find the pages where I need to replace the 'define'? I know you said at the top of every vB page, but where do I find those? Sorry if this is a novice question.

Maybe I wasn't clear. Where do I find the pages where I need to replace the 'define'? I know you said at the top of every vB page, but where do I find those? Sorry if this is a novice question.
Did you look at any of the pages? The line I quoted in my last post is line
17 in the online.php page. And line 17 of the forum.php page defines THIS_SCRIPT for that page to be 'index'. And for content.php, THIS_SCRIPT is defined at 'vbcms'. I believe any page in vb that you can land on has got THIS_SCRIPT defined at the top. And you don't want to replace those lines, I'm not sure why you would think you would want to do that. Those lines are there so you can write conditions like the one I use for when you are on that page. If you wrote your own page, you would give it your own definition for THIS_SCRIPT.

I'm sorry if I'm making this out to be more complicated than it needs to be, but I must be missing something. Here is your code from the first page:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'yourpage')
{
$vbulletin->options['selectednavtab']='unique_name';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

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

I replaced 'yourpage' with 'podcast', and 'unique_name' with 'podcast'. I also changed the 'Nav Link' href and name at the bottom of the script to look like:

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="/forums/content/116-podcast">Podcast</a>'.$tablinks.'</li>' ;

It appears to me that these are the only changes required. What I don't understand is where I'm suppose to find the define('THIS_SCRIPT', '<name>');. You said it's at the top of the page, so I went to the actual podcast CMS page I created and looked at the Page Source in my browser but this code doesn't exist. So where is it located?

THIS_SCRIPT is defined at the top of the php page, not some browser page, but in the actual code. Open up the file called forum.php that you downloaded from vbulletin.com to install on your server and you will see the line I am talking about.

I don't think (or rather, I don't know of the condition) you can do this for a CMS page. All those pages are using the content.php page and right now, if you are on a content.php page, the Home link is highlighted. I don't know what the condition is for a particular Article, which is what it sounds like you want to do. You'd have to look in through the code to figure that out and I haven't got that far into the CMS yet.

So you're saying I do need to create a custom vBulletin page, and this NavBar technique can't work with a CMS created page, right?

So you're saying I do need to create a custom vBulletin page, and this NavBar technique can't work with a CMS created page, right?
No, you don't need to create a custom page. That condition I posted is an EXAMPLE of a condition to use. Most people will use THIS_SCRIPT as the condition. But, you could use forumids or threadids or who-knows-what-else - as long as the condition is UNIQUE. And, I don't know that it won't work on a CMS created page. It probably could if you find the correct unique condition. I simply don't know what that condition would be since I haven't looked that closely into the CMS pages and the attributes that are passed to them.

Lovely it works like a charm, lynne to the rescue ;)

:D

It work in RC2?? because the selected function and the drop down menu doesn't appear for me.

It work in RC2?? because the selected function and the drop down menu doesn't appear for me.
Worked fine for me in RC2 and in the current version, RC4.

on my RC2 the function selected doesn't work....

on my RC2 the function selected doesn't work....
Then you probably don't have your condition written correctly, but from the (non-existant) information you've posted, it's hard to say.

This is what i use

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Downloads')
{
$vbulletin->options['selectednavtab']='Downloads_tab';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="/resources/">Downloads</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Test Link 1</a></li>
<li><a href="sublink2.php">Test Link 2</a></li>
<li><a href="sublink3.php">Test Link 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://mysite.com/resources/">Downloads</a>'.$tablinks.'</li>' ;

But when the page is selected the button doesn't work properly.

I noticed someone else attempting to have the plugin work for multiple pages, they solved it but didn't share how they did so.

I am also attempting to have the same tab be highlighted for multiple pages (the ones linked in the navbar when you click on the tab), but can't seem to figure it out.

Any help would be much appreciated!

http://www.npac.ca/2010

This is what i use

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'Downloads')
{.....
But when the page is selected the button doesn't work properly.

Is that condition valid? Do you have a line at the top of your downloads page that defines THIS_SCRIPT as "Downloads" (must use exact word - if capitalized in the php, then it must be capitalized in the condition).

I noticed someone else attempting to have the plugin work for multiple pages, they solved it but didn't share how they did so.

I am also attempting to have the same tab be highlighted for multiple pages (the ones linked in the navbar when you click on the tab), but can't seem to figure it out.

Any help would be much appreciated!

http://www.npac.ca/2010
And are you conditions valid to make those tabs active?

Oh actually they are not all set up just yet. It works as it should for 'Contests' - however I want Contests to remain highlighted when on the pages within that section.

From: http://npac.ca/2010/contests.php

Contests -> NPOY 2009 -> Information & Rules

Takes you to: http://npac.ca/2010/poy2009.php

Above is where I am working on first, and trying to figure out how to get it working for that page before moving on to the rest (which still need to be created).

This is my first time working with vBulletin, so am still getting used to conditions. I'm more of a designer than developer, but do have a firm understanding when it comes to the code.

Is that condition valid? Do you have a line at the top of your downloads page that defines THIS_SCRIPT as "Downloads" (must use exact word - if capitalized in the php, then it must be capitalized in the condition).


And are you conditions valid to make those tabs active?

This is not a custom page, but it is a section of my community that i wat to show on navbar_tab.

Oh actually they are not all set up just yet. It works as it should for 'Contests' - however I want Contests to remain highlighted when on the pages within that section.

From: http://npac.ca/2010/contests.php

Contests -> NPOY 2009 -> Information & Rules

Takes you to: http://npac.ca/2010/poy2009.php

Above is where I am working on first, and trying to figure out how to get it working for that page before moving on to the rest (which still need to be created).

This is my first time working with vBulletin, so am still getting used to conditions. I'm more of a designer than developer, but do have a firm understanding when it comes to the code.
Then is sounds more like you should have a longer condition: if on Contests page or on poy2009 page or on xxxxx page. So, you could define THIS_SCRIPT at the top of each of those pages so you can use them in the condition:
if (in_array(THIS_SCRIPT, array('contests', 'poy2009', 'xxxxx')))You will NEED to define THIS_SCRIPT at the top of all those pages!!!!
define('THIS_SCRIPT', 'xxxxx');This is not a custom page, but it is a section of my community that i wat to show on navbar_tab.
Then you need to have a condition written to make that tab show for that section. I cannot help you with that as I am not that familiar with the CMS yet.

Lynne,

I am trying to set up a tab, and link it to a forum, basically a section kind like how Vbulletin.org has it. However, when I try to set an array on forums inside the sub, it wont highlight.

Here is my condition I have set.

if (in_array($forum['forumid'], array(13,22)))

--------------- Added 1261123033 at 1261123033 ---------------

Nevermind...lol figured it out.

If anyone else needs this the code is:
if (in_array($foruminfo['forumid'], array(13,22,35,19,24,59,60,93,94,36,61,62,21)))

Thanks Lynne,

That condition you wrote did not work, but I found a simpler solution:

I simply defined THIS_SCRIPT as 'contests' in poy2009.php

Not sure if that will cause any conflicting problems, but it seems to be working fine.

I looked but did not find the answer. How do you add a phrase in this code for Sublink 1?

<li><a href="sublink1.php">SubLink 1</a></li>

I tried ' . $vbphrase['my_phrase'] .'
I tried {vb:rawphrase my_phrase}

never mind ... I needed to globalize it


Try the first without ' ' in phrase. eg ' . $vbphrase[my_phrase] .'

Maria

Try the first without ' ' in phrase. eg ' . $vbphrase[my_phrase] .'

Maria

Hi,

Actually I had to

global $vbphrase;

Thank you Lynne, this is extremely helpful :)

Thanks, Lynne! Worked perfectly for me with no issues.

Edit: One quick question, is there a way to use a condition to show the sublinks/dropdown links to just a certain usergroup? I tried a template condition, but that didn't work.

Thanks, Lynne! Worked perfectly for me with no issues.

Edit: One quick question, is there a way to use a condition to show the sublinks/dropdown links to just a certain usergroup? I tried a template condition, but that didn't work.
I believe there are examples of how to do that on pages 2 and 4 of this thread.

Sorry about that, I just read the entire thread and saw that.

Thanks again

I just want to add in a simple link on the nav bar so I tried this and tried just removing the navlinks section of the code. The result was that my Blogs link disappeared and that was all.

What do I need to do to make this just a link on the nav bar to an external site (the add-on has problems and I'd prefer to have everything done "properly")

There are mods to just add a simple link with no submenu. You are probably better off just using one of them.

Hello!

Ive read through the entire thread, and managed to get it all working by the end!! Thanks Lynne, for all your detailed replies, it really helped me to get it working.

Im stuck at one last thing though.......how do I get all the links in the sub menu to stay on the new tab when you click on them?

I have all my links in the sub menus going to VB Pages (http://www.vbulletin.org/forum/showthread.php?t=228112) Ive created myself.

But when I click on each link, while it takes me to the new VB page Ive created, the tab and submenu returns to the Forum tab.

Ive played around with it a bit, but cant figure out how to make it work with multiple pages.....?

Please let me know if you need any additional info to help you understand what it is Im trying to do.

Is there a way to replace tabs with images?

Great post Lynne! I'm not that great at hacks, but I managed to get this to work for a CMS news section. I thought others may want to know how to do this too. This is how I did it:

Copy the original vBulletin file "content.php" and save as "about.php" (or whatever filename you wish)

In your new about.php file Change:

define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'vbcms');
to
// define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'about_ridehub');

Ensure you comment out the first line as shown about, this stops the default CMS section links from showing in the lower area. I used "about_ridehub' for THIS_SCRIPT, but you can use anything you want, just make sure it is unique and set as per this How-To.

Upload your new .php file to forum root.

Make sure the CMS section you want this new nav bar to work with is "Not Published" otherwise Google will find duplicate content. This can be done in the Section Manager in the AdminCP.

Now instead of linking to (for example):
http://www.yoursite.co.uk/content.php/48-About

You can use:
http://www.yoursite.co.uk/about.php/48-About

Add these links to the menu bar, and it should all work ok.

See here for an example:
http://www.ridehub.co.uk/about.php/48-What-is-RideHub

I have all my links in the sub menus going to VB Pages (http://www.vbulletin.org/forum/showthread.php?t=228112) Ive created myself.

But when I click on each link, while it takes me to the new VB page Ive created, the tab and submenu returns to the Forum tab.

Ive played around with it a bit, but cant figure out how to make it work with multiple pages.....?

Please let me know if you need any additional info to help you understand what it is Im trying to do.
In the plugin code is a condition that sets when your tab is 'selected'. In my example I have this condition:
if (THIS_SCRIPT == 'yourpage')
If you want it to stay highlighted for... say... all threads in forumids 11, 12, and 13 also, then you need to add in that condition:
if (THIS_SCRIPT == 'yourpage' OR in_array($GLOBALS['forumid'], array(11, 12, 13)))

I'm not sure what your condition would be since you didn't really verbalize it, but I hope what I wrote helps.

Thanks for the reply Lynne.

I want the tab to stay selected, when I am on any of the pages in the submenu of the new tab.

Looks like it might be easier to show you the code? Its only going to make it easier for others trying to do the same thing to understand too :)

I have created a new tab called "Site Info'. I have also created my own VB page for it to link to.

This is the code for the plug in:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'ip_site_information')
{
$vbulletin->options['selectednavtab']='ip_site_information';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="our_philosophy.php">Our Philosophy</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Advertising</a>
<ul class="popupbody popuphover">
<li><a href="banner_advertising.php">Banner Advertising</a></li>
<li><a href="sig_advertising.php">Signature Advertising</a></li>

</ul>
</li>
<li><a href="donations.php">Donations</a></li>
<li><a href="sendmessage.php.php">Contact Us</a></li>
</ul> ';

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

and this is the condition in my 'Site Info' VB page I created:

define('THIS_SCRIPT', 'ip_site_information');

Everything works as it should with all the above code for the Site Info tab & Page.

I have 4 other VB pages (http://www.vbulletin.org/forum/showthread.php?t=228112) I created myself. They are the the ones listed in the submenu of the new tab "Site Info' See first image attached.

For these 4 links in the submenu, the condition in each of their VB pages is as follows:

Our Philosophy Page:
define('THIS_SCRIPT', 'our_philosophy');

Advertising is a drop down menu, so contains the 2 links, 'Sig Advertising' and 'Banner Advertising' that have their own VB pages.

Sig Advertising Page:
define('THIS_SCRIPT', 'sig_advertising');

Banner Advertising Page:
define('THIS_SCRIPT', 'banner_advertising');

Donations Page:
define('THIS_SCRIPT', 'donations');

Now when I click on any of these links, you can see what happens in the second attached image, that while it takes me to the page I want it to, the tab thats selected is the Forum tab and all its submenus. Where as I want the new tab, 'Site Info' and all its submenus to remain selected when I click on these submenu links.

Try this then (I think I got them all):
if (in_array(THIS_SCRIPT ,array('ip_site_information', 'our_philosophy', 'sig_advertising', 'banner_advertising', 'donations')))

ahhhh!!! I was trying to figure out how to get them all in there! Works perfectly! Thank you!! :D

For anyone looking to do this, I have replaced this part of the plug in code:

if (THIS_SCRIPT == 'ip_site_information')


With this from the post above:
if (in_array(THIS_SCRIPT ,array('ip_site_information', 'our_philosophy', 'sig_advertising', 'banner_advertising', 'donations')))

Hello,

Why I can't add to the left side? I tried:

$template_hook['navtab_left']

but it didn't worked. Changing to 'navtab_middle' works fine. Actually I want to place it at very first (before Forums). Maybe I need to use a diffent hook place than process_templates_complete ?

Thank you
Maaria

Hello,

Why I can't add to the left side? I tried:

$template_hook['navtab_left']
but it didn't worked. Changing to 'navtab_middle' works fine. Actually I want to place it at very first (before Forums). Maybe I need to use a diffent hook place than process_templates_complete ?

Thank you
Maaria
You want navtab_start, not navtab_left. (There is no navtab_left.)

So, after a bit of time reading a bunch of stuff in this thread (coupled with your HOW TO on adding pages) I've got this all figured out.

For the people that seem to be trying to grasp exactly what to do, it's probably best to follow this thread http://www.vbulletin.org/forum/showthread.php?t=228112 in order to create the link.php (or whatever you want to name it). Then everything else will make a lot more sense I think. Because then you'll actually have a webpage, that when you click on Nav Link, you'll be directed to and you'll be able to see the sublink and dropdown menus. After I did that up and read through the thread again it made a bit more sense. I hope that helps some people.

Lynne, you are great! Thanks again.

Because this is plugin form there won't be any problems when we update vB, right?

Because this is plugin form there won't be any problems when we update vB, right?
Unless they somehow screw up plugin locations or template_hook names or totally change the navbar or something like that, then this should be fine when you update vB.

Thought so. Great! Template edits are just a pain to deal with that's why I love this plguin.

Here is an Add-on i made to help the Nab Tab Drop Down Issues. Its a Easy Plugin code that can be Duplicated for another tab in the same Plugin!

http://www.vbulletin.org/forum/showthread.php?p=1946819 (http://www.vbulletin.org/forum/showthread.php?t=232134)

Let Me know If this Works!

Thanks!

Great post Lynne! I'm not that great at hacks, but I managed to get this to work for a CMS news section. I thought others may want to know how to do this too. This is how I did it:

Copy the original vBulletin file "content.php" and save as "about.php" (or whatever filename you wish)

In your new about.php file Change:

define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'vbcms');to
// define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'about_ridehub');Ensure you comment out the first line as shown about, this stops the default CMS section links from showing in the lower area. I used "about_ridehub' for THIS_SCRIPT, but you can use anything you want, just make sure it is unique and set as per this How-To.

Upload your new .php file to forum root.

Make sure the CMS section you want this new nav bar to work with is "Not Published" otherwise Google will find duplicate content. This can be done in the Section Manager in the AdminCP.

Now instead of linking to (for example):
http://www.yoursite.co.uk/content.php/48-About

You can use:
http://www.yoursite.co.uk/about.php/48-About

Add these links to the menu bar, and it should all work ok.

See here for an example:
http://www.ridehub.co.uk/about.php/48-What-is-RideHub


This works until you click on a category or article then it reverts back to selecting home. Any idea on a fix?

Yeah - the items listed within the main page body do refer back to the original php file. I'm trying to think of a way around this. I'll post when I figure it out.

i only needed the links in the main navbar so for me this worked...

$tabselected = '';
$tablinks = '';
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://xxxxxxxxxx/payments.php">Buy VIP!</a>'.$tablinks.'</li>' ;

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://xxxxxxxxxx/" target="_new">xxxxxxxx</a>'.$tablinks.'</li>' ;

but im still trying to figure out how to put a gap after the nav buttons end and then another one near the other side, connected to the search bar

--------------- Added 1262861307 at 1262861307 ---------------

yea i tryed but i still cant figure out how to make one link stay at the far right instead of beside each other, a space and it shows at the very end of the bar...

i tried <ul style='float:right'> but even if that worked its probably not the best coding so some help would be appreciated

Yeah - the items listed within the main page body do refer back to the original php file. I'm trying to think of a way around this. I'll post when I figure it out.


About the only thing I've come up with is to remove all class="selected" for vbcms then write a plugin to specify what to select based on section id. Has to be an easier way though :(

Excellent mod, works great. Has anyone figured out an easy way to use templates to pupulate the pages upon sub menu link clicks or does it have to be external or new page links?

I tried the 48-What-is-RideHub suggestions but my home tab always stays selected and it was very buggy for me.

The site I am working to complete is http://deathcompanygaming.net/epeenery/

On my roster page I would like to use the dropdown menu to populate our roster for each game. I haven't been able to get jquery to be very stable and play nice with vB4 yet so is there an onclick event that will load templates into a particular div tag that can be used in the link?

Hey Lynne!! I have used this code, but I can't seem to get it to work, or part of it to work. I have modified the code and it is shown below.

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'status')
{
$vbulletin->options['selectednavtab']='radio_tab_001';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="#">About</a></li>
<li><a href="schedule.php">Schedule</a></li>
<li><a href="status.php">Status</a></li>
</ul> ';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="status.php">Radio</a>'.$tablinks.'</li>' ;

I have made two pages, schedule and status. The about page has not been made yet but it in the process of being made using your HOW-TO (thanks for that one!!). When I click the "Radio" section on the biggest bar, it selects itself and highlights as it should, but then when I go to the schedule.php link it goes back to the Forum tab.

You can see it in action if you wish at http://forum.pukkaradio.net

Cheers for any help that may come of this!!

I have made two pages, schedule and status. The about page has not been made yet but it in the process of being made using your HOW-TO (thanks for that one!!). When I click the "Radio" section on the biggest bar, it selects itself and highlights as it should, but then when I go to the schedule.php link it goes back to the Forum tab.

You can see it in action if you wish at http://forum.pukkaradio.net

Cheers for any help that may come of this!!
You need to make your condition cover *all* the pages you wish it to stay highlighted for. If your schedule.php page has THIS_SCRIPT defined as 'schedule', then change the condition to this:
if (in_array(THIS_SCRIPT, array('status', 'schedule')))

Awesome!! Thanks ever so much Lynne!!

Hi All.
Browsed through this entire thread and I am still no wiser to my predicament. what I would like to do is simply add an extra standard Navbar Tab which will redirect the user to my other external website.

Example
"www.myadvertising-program.com"

https://www.vbulletin.org/forum/

Thanks.

To keep the tab highlighted for my sublinks I just added the or statement to the beginning and used multiple php files.

if (THIS_SCRIPT == 'recruitment.php' || THIS_SCRIPT == 'recruitment_status.php' || THIS_SCRIPT == 'epeen_application.php')

Hi All.
Browsed through this entire thread and I am still no wiser to my predicament. what I would like to do is simply add an extra standard Navbar Tab which will redirect the user to my other external website.

Example
"www.myadvertising-program.com"

http://i744.photobucket.com/albums/xx90/simonwhitehead/Capture.jpg

Thanks.

If that is all you want to do, there is a MOD for that.

vBH-Add new tabs
http://www.vbulletin.org/forum/showthread.php?t=228507

Lynne,

How would I construct the if condition for a link like so:
misc.php?do=rules

Lynne,

How would I construct the if condition for a link like so:
misc.php?do=rules
Perhaps something like:
if (THIS_SCRIPT == 'misc' AND $_REQUEST['do'] == 'rules')

Perhaps something like:
if (THIS_SCRIPT == 'misc' AND $_REQUEST['do'] == 'rules')

Tried that before and didn't work, did it again then realized I needed to change my template.

Thanks

Lynne,

Is there any way to add an extra tab using this method, while retaining the same tablinks as are used on the Forum tab?

For my example, I'm trying to add a "Home" tab for vBa CMPS, but want to keep all the links you find on the Forum one.

You may just copy all the links for the Forum tab.

I'm trying to create a forum for Traveling. I've downloaded and installed vBh that allows me to add extra tabs. These tabs only link to another site.

I want to create a Nav menu like this "Forum | Travel | Hotels | Car Rental"

When the user clicks on a tab, it will open the tab in the same window but it would be about the topic the user click on. I've seen on other sites that this is possible. Just wondering how it's done. Please provide some details. I'm on vB 4.0.1, just in case you need to know the version. Thanks.

I can't tell you how to use the other mod - I have no idea how it works. This article will tell you how to create a navtab, such as Travel, and you link it to your forumdisplay.php page for that forum. If you want the tab highlighted at that point, then do an if condition based on the $forumid.

Hi Lynne,
This might either be slightly off topic or may perhaps help others if added to your initial post. My search on changing tab order didn't return any useful results. However if whatever I've written is a commonly known solution, please disregard and delete the post :)

All,
It seems many people have asked about reordering tabs in the nav bar.

As mentioned in many places there are three template hooks which allow you to place your new tab:
- navtab_start
- navtab_middle
- navtab_end

Lynne has used the navtab_end hook which is in the last line of the PHP Code:
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;

I'm going to assume the default tabs as:
Forum | Blogs | What's New

If we use the Lynnes way of creating a tab as explained here (http://www.vbulletin.org/forum/showthread.php?t=226914), but use the navtab_middle hook like:
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;
then the new tab comes between Forum and Blogs. But we want to add the tab after Blogs. To move over the new tab after Blogs just change the execution order from 5 to 6. So by using different execution orders in different plugins you can place your tabs in any order you want within the same template hook. You could of course generate all tabs from one plugin and use code execution order to place the tabs.

This is the only reliable solution I have found and am using it on my own forum (img attached). I'm open to other methods as well.

Cheers

Lynne,

Can you post the link.php code you mention in the very first post of the thread.

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;

I would like to see how link.php is written.

Thanks.

Lynne,

Can you post the link.php code you mention in the very first post of the thread.

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;

I would like to see how link.php is written.

Thanks.
link.php is a fictitious page. It is whatever page you want to link to.

link.php is a fictitious page. It is whatever page you want to link to.


I understand that. I just want to see how another page is written, which variable is need to recreate the same page as forum.php but displaying a different information. I know how to code php but don't know the structure of how vbulletin assembles its code.

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'album.php')
{
$vbulletin->options['selectednavtab']='for_pics';
$tabselected = ' class="selected"';

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


What am I doing wrong here? All I want is a button (no sub menu). Everything works fine except the Forum button is selected instead when clicking the Albums button.

I understand that. I just want to see how another page is written, which variable is need to recreate the same page as forum.php but displaying a different information. I know how to code php but don't know the structure of how vbulletin assembles its code.
This may help - [HOW TO - vB4] Create a own vBulletin page (http://www.vbulletin.org/forum/showthread.php?t=228112)


$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'album.php')
{
$vbulletin->options['selectednavtab']='for_pics';
$tabselected = ' class="selected"';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="album.php">Albums</a>'.$tablinks.'</li>' ;
What am I doing wrong here? All I want is a button (no sub menu). Everything works fine except the Forum button is selected instead when clicking the Albums button.
If you look at the top of your album.php page, you will see THIS_SCRIPT defined here:
define('THIS_SCRIPT', 'album');
You put 'album.php' instead of the correct 'album' in the conditional. Change it.

Thank You! :)

I've just read this thread - and I may have missed something... in which case I apologise up front! Having said that... I'm also somewhat (ok, a lot) confused...

I would like to add a new tab called HOME and I would like to have it display on ALL pages throughout my site.

Could someone please help me with this? Or point me in the right direction pls?

Thanks in advance...

If you create a new navtab via a plugin (like in this mod), it will show on all your pages.

Hi Lynne

Thanks... you mean as in the very first post? I hope you can understand I was a little confused by the time I had read all of the posts...

Cheers
Wormy

--------------- Added 1264122352 at 1264122352 ---------------

Wow... I followed the first post and bingo... all done in a matter of about 2 minutes.

Next time I'll give the opening post/tutorial a go before I read ALL of the posts in the thread :)

Thanks SO much Lynne!!

--------------- Added 1264122480 at 1264122480 ---------------

One QQ... is it possible to have the hiughlight line above the button appear (like the default buttons in VB)?

One QQ... is it possible to have the hiughlight line above the button appear (like the default buttons in VB)?
You make the tab be active, or highlighted, by setting the condition correctly for the submenu.

You make the tab be active, or highlighted, by setting the condition correctly for the submenu.

Hmmm... how/where do I do that? Please :)

I'm trying to get the standard highlight/floating bar which shows above the tab...

Thank you!!

--------------- Added 1264124054 at 1264124054 ---------------

If I follow your tutorial... should that not be the case? Apologies for all the questions...

In my plugin is this line:
if (THIS_SCRIPT == 'yourpage')

I later say that this must be a unique condition for your tab page to be highlighted. What do you have for that condition?

Thanks Lynne...manage to create also this great tutorial from you....just can't figure it out how to hide this DropDown Menu to Guest...tried the one you mention above but no luck...

can you please assist me here...


<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down Menu</a>
<ul class="popupbody popuphover">

<li><a href="arcade.php?&act=Arcade&module=settings">Settings</a></li>

<li><a href="arcade.php?&act=Arcade&module=favorites">Favorites</a></li>

<li><a href="arcade.php?&act=Arcade&module=report">Rankings</a></li>
</ul>
</li>

</ul> ';


thanks and best regards...

;):up:

Thanks Lynne...manage to create also this great tutorial from you....just can't figure it out how to hide this DropDown Menu to Guest...tried the one you mention above but no luck...

can you please assist me here...

Please post your whole plugin, not just part of it.

<li><a href="arcade.php?&act=Arcade&do=createtourney">Create New Tournament</a></li>


<li class="popupmenu">
<a href="javascript://" class="popupctrl">Misc. Menu</a>
<ul class="popupbody popuphover">


<li><a href="arcade.php?&act=Arcade&module=settings">Settings</a></li>

<li><a href="arcade.php?&act=Arcade&module=favorites">Favorites</a></li>

<li><a href="arcade.php?&act=Arcade&module=report">Rankings</a></li>

</ul>

<li class="popupmenu">
<a href="javascript://" class="popupctrl">Games Menu</a>
<ul class="popupbody popuphover">





just like i said just want to hide the Misc. Menu to Unregistered Groups... or else everthing....

...
<li><a href="arcade.php?&act=Arcade&do=createtourney">Create New Tournament</a></li>';

if (is_member_of($vbulletin->userinfo, x))
{
$tablinks .= '<li class="popupmenu">
<a href="javascript://" class="popupctrl">Misc. Menu</a>
<ul class="popupbody popuphover">
<li><a href="arcade.php?&act=Arcade&module=settings">Settings</a></li>
<li><a href="arcade.php?&act=Arcade&module=favorites">Favorites</a></li>
<li><a href="arcade.php?&act=Arcade&module=report">Rankings</a></li>
</ul></li>';
}

$tablinks .= '<li class="popupmenu">
<a href="javascript://" class="popupctrl">Games Menu</a>
<ul class="popupbody popuphover">
...Change the x in the condition to the usergroupid you want to show it to. Or use this:
if (!is_member_of($vbulletin->userinfo, x))and change the x to the usergroupid you do NOT want to show it to.

fantastic Lynne....thanks once again for your help... ;):up:

how do I put the tab before the "What's New?" tab and not after it?

Read the article:
You may use a different template_hook here - it just depends on where you want your tab to be - navtab_start and navtab_middle are also available.

I don't have these hook locations...

I don't have these hook locations...
If you don't have them, then you removed them and you will have to add them back. (We are talking about the *tempate_hook* locations here, not the plugin hook location.)

oops, my bad...

but 'navtab_middle' puts it before the blogs tab, how do I put it between the blogs tab and the what's new tab?

Change the Execution Order of the plugin.

I'd like to make a blog category into a tab while at the same time not activating the Blogs tab. Would this be the proper format?

if ((THIS_SCRIPT == 'blog') && ($_REQUEST['do'] == 'list' && 'blogcategoryid=1'))

I'd like to make a blog category into a tab while at the same time not activating the Blogs tab. Would this be the proper format?

if ((THIS_SCRIPT == 'blog') && ($_REQUEST['do'] == 'list' && 'blogcategoryid=1'))
You'll have to just try it and see. If you have the regular blog tab disabled, then I don't think it is going to interfere with that one, so I would guess it should work.

Hi Lynne,

Been trying to figure this one out.

All I want to do is add a new tab that displays the following....

...search.php?do=getdaily&contenttype=vBForum_Post&include=27,35,59,76,84,85

That gives me todays posts from a select group of forums that I have as sales forums. By clicking on the tab, my members can view "Todays Ads".

The tab works, in so far as it throws up the right results, but it doesnt stay selected. I believe this is because THIS_SCRIPT is "search" which is not unique. Do you know of any way to resolve this? I dont want submenus or anything else, I just want to put this link in the tabs at the top of my forum.

I've tried the different tabs mods, I've tried tabs with templates and your mod and the same problem occurs with all of them. At this point, I'm thinking how bad is a piece of software that wont allow a simple link to be added to the menu system? I'm generally liking vB4, but the navbar is truly awful. I'm starting to think this is not actually possible.

Hi Lynne,

Been trying to figure this one out.

All I want to do is add a new tab that displays the following....

...search.php?do=getdaily&contenttype=vBForum_Post&include=27,35,59,76,84,85

That gives me todays posts from a select group of forums that I have as sales forums. By clicking on the tab, my members can view "Todays Ads".

The tab works, in so far as it throws up the right results, but it doesnt stay selected. I believe this is because THIS_SCRIPT is "search" which is not unique. Do you know of any way to resolve this? I dont want submenus or anything else, I just want to put this link in the tabs at the top of my forum.

I've tried the different tabs mods, I've tried tabs with templates and your mod and the same problem occurs with all of them. At this point, I'm thinking how bad is a piece of software that wont allow a simple link to be added to the menu system? I'm generally liking vB4, but the navbar is truly awful. I'm starting to think this is not actually possible.
You could include an "AND $_REQUEST['do'] == 'getdaily'" in the condition. You may have to modify the condition for What's New in the navbar also so that yours may become active (AND $_REQUEST['do'] != 'getdaily').

Hi there, Lynne. :)

I had a question related to tabs. I actually created a separate thread (http://www.vbulletin.org/forum/showthread.php?t=234953)for it, but somehow it hasn't got answered yet.

Actually, in the tabs, I wanted to add icons / images along with the link as well. e.g. add a home icon in the Home tab (on the left of "Home" text). The only thing I couldn't figure out was where exactly would I need to add the image source for the desired icon?

I messed around a bit, and in "blog_navbar_link" found the following code:

<li><a class="navtab" href="blog.php{vb:raw session.sessionurl_q}">{vb:rawphrase blogs}</a></li>

Then, I changed it to this:

<li><a class="navtab" href="blog.php{vb:raw session.sessionurl_q}"><img class="inlineimg" src="http://forums.pakfellows.com/images/icons/Homepage/blog.png" border="0" />{vb:rawphrase blogs}</a></li>

This inserted the image in the correct place (see screenshot), but I would like to have it so that the word "Blogs" remains in the center of the tab, i.e. both image and text are inline instead of Blogs being pushed down.

Could you help me with this please? :)

Hi,

How do set permissions on just e.g. The line with Misc in it.

I only want that to show to certain Groups.

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


$tablinks .= ' <ul class="floatcontainer">

<li><a href="account.php">My Account</a></li>
<li><a href="shopping_cart.php">Cart Contents</a></li>
<li><a href="misc.php">Misc</a></li>
<li><a href="checkout_shipping.php">Checkout</a></li>
</ul> ';
}

Hi,

How do set permissions on just e.g. The line with Misc in it.

I only want that to show to certain Groups.

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


$tablinks .= ' <ul class="floatcontainer">

<li><a href="account.php">My Account</a></li>
<li><a href="shopping_cart.php">Cart Contents</a></li>
<li><a href="misc.php">Misc</a></li>
<li><a href="checkout_shipping.php">Checkout</a></li>
</ul> ';
}
Look around page 2 or 3 or so of this article and you will see this question already answered.
Hi there, Lynne. :)

I had a question related to tabs. I actually created a separate thread (http://www.vbulletin.org/forum/showthread.php?t=234953)for it, but somehow it hasn't got answered yet.

Actually, in the tabs, I wanted to add icons / images along with the link as well. e.g. add a home icon in the Home tab (on the left of "Home" text). The only thing I couldn't figure out was where exactly would I need to add the image source for the desired icon?

I messed around a bit, and in "blog_navbar_link" found the following code:

<li><a class="navtab" href="blog.php{vb:raw session.sessionurl_q}">{vb:rawphrase blogs}</a></li>Then, I changed it to this:

<li><a class="navtab" href="blog.php{vb:raw session.sessionurl_q}"><img class="inlineimg" src="http://forums.pakfellows.com/images/icons/Homepage/blog.png" border="0" />{vb:rawphrase blogs}</a></li>This inserted the image in the correct place (see screenshot), but I would like to have it so that the word "Blogs" remains in the center of the tab, i.e. both image and text are inline instead of Blogs being pushed down.

Could you help me with this please? :)
That really doesn't have anything to do with this article. It is a CSS issue. You can use firebug to play with the css and get it right.

I got as far as this:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'osc_shop')
{
$vbulletin->options['selectednavtab']='oscShop';
$tabselected = ' class="selected"';
if (is_member_of($vbulletin->userinfo, 6))
{
$tablinks = '<ul class="floatcontainer">
<li><a href="misc.php">Misc</a></li>

</ul>';
}
if ($vbulletin->userinfo['userid'])
{
$tablinks .= '<ul class="floatcontainer">
<li><a href="account.php">My Account</a></li>
<li><a href="shopping_cart.php">Cart Contents</a></li>
<li><a href="checkout_shipping.php">Checkout</a></li>

</ul> ';

}
}

$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="shop.php">Shop</a>'.$tablinks.'</li>' ;

But My Account is on top of Misc.

Can anyone help with this, please.

Take a look at the code in the first post again. You are closing the <ul> tag before you are supposed to. It should be open for all submenu items.

I have looked the first post again, but still can't get it working.

Any chance you could fix it please.

Assuming your code was correct to begin with, this should work:
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'osc_shop')
{
$vbulletin->options['selectednavtab']='oscShop';
$tabselected = ' class="selected"';
if ($vbulletin->userinfo['userid']) $tablinks = '<ul class="floatcontainer">';
if (is_member_of($vbulletin->userinfo, 6))
{
$tablinks .= '<li><a href="misc.php">Misc</a></li>';
}
if ($vbulletin->userinfo['userid'])
{
$tablinks .= ' <li><a href="account.php">My Account</a></li>
<li><a href="shopping_cart.php">Cart Contents</a></li>
<li><a href="checkout_shipping.php">Checkout</a></li>

</ul> ';

}
}

$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="shop.php">Shop</a>'.$tablinks.'</li>' ;

Thank you for that. It works perfect.

Hi Lynne, thanks for another great guide :) (Yes, I'm a suck up).

Just wondering if could have it so the sublink menu popup menu can be displayed when hovering your pointer over it instead of having to click, is there an in-built JS within VB to do this or would I have to use an external one?

Hi Lynne, thanks for another great guide :) (Yes, I'm a suck up).

Just wondering if could have it so the sublink menu popup menu can be displayed when hovering your pointer over it instead of having to click, is there an in-built JS within VB to do this or would I have to use an external one?
Could probably do it with javascript or some creative css, but I haven't looked into it.

Thanks Lynne. :)

i want to add a new "nav link" to go to the privet messages.

like in this original photo- how can i do that ?

https://www.vbulletin.org/forum/external/2011/07/104.jpg

Can this plugin call variables from my custom page?

I'm looking to use this menu to sort the tables on my custom page. My custom page creates an array (which you may be familiar with in another post):

$columns = array(
'column1' => $field1st,
'title1' => $title1st,
'column2' => $field2nd,
'title2' => $title2nd,
'column3' => $field3rd,
'title3' => $title3rd,
'column4' => $field4th,
'title4' => $title4th,
'column5' => $field5th,
'title5' => $title5th,
'column6' => $field6th,
'title6' => $title6th,
'column7' => $field7th,
'title7' => $title7th,
'column8' => $field8th,
'title8' => $title8th
);

Anyhow, instead of link1, I'd like to use $columns['title1'] in this plugin.

i want to add a new "nav link" to go to the privet messages.

like in this original photo- how can i do that ?

https://www.vbulletin.org/forum/external/2011/07/104.jpg
Did you read the article? What code have you written to try to do what you want and what were the results? I can't tell you want is wrong unless you post your code and an image of the result and you tell us what is wrong with the result.

Can this plugin call variables from my custom page?

I'm looking to use this menu to sort the tables on my custom page. My custom page creates an array (which you may be familiar with in another post):

$columns = array(
'column1' => $field1st,
'title1' => $title1st,
'column2' => $field2nd,
'title2' => $title2nd,
'column3' => $field3rd,
'title3' => $title3rd,
'column4' => $field4th,
'title4' => $title4th,
'column5' => $field5th,
'title5' => $title5th,
'column6' => $field6th,
'title6' => $title6th,
'column7' => $field7th,
'title7' => $title7th,
'column8' => $field8th,
'title8' => $title8th
);Anyhow, instead of link1, I'd like to use $columns['title1'] in this plugin.
I don't know. I've never tried what you want to do. You'd have to make your variables available to the plugin by defining them prior to this plugin being rendered. So, depending on how you go about it, you should be able to do what you want.

I don't know. I've never tried what you want to do. You'd have to make your variables available to the plugin by defining them prior to this plugin being rendered. So, depending on how you go about it, you should be able to do what you want.

Thanks for the reply Lynne. That's actually my question. How do I make the variables available to the plugin. Perhaps this isn't a question for this thread now that I think about it. I'll look around some more and maybe just post it in the Programming forum instead. Thanks Lynne. :)

hii - i donnt want to make what you do in this articles ,.
i want to add NAV LINK - not a drop down menu !

hii - i donnt want to make what you do in this articles
If you start a post in an article thread with this sentence, you can be sure that you are off topic. Because article threads are for what is discussed in the article. If you want to do something else, you need to open your own thread.

Thanks very much for this (and your create own page tutorial) Lynne, your work is massively appreciated.

Can I be a pain and ask your advice? I am attempting to include two tabs on my test forum. One works fine, not a problem but the second tab doesn't remain highlighted once clicked. I've read through the thread and fiddled with it for over an hour, any possible chance you could have a look at my code and identify the problem?

Working Tab;

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'newsfeed')
{
$vbulletin->options['selectednavtab']='newsfeed';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="/testvb/newsfeed.php">Latest EFC News Feed</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Events</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Diary of Events</a></li>
<li><a href="sublink2.php">Forthcoming Everton Events</a></li>
<li><a href="sublink3.php">Official Facebook Events Group</a></li>
</ul>
</li>
<li><a href="link2.php">Supporter Clubs</a></li>
<li><a href="link3.php">Visitors Guide</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.grandoldteam.com/testvb/newsfeed.php">News Feed</a>'.$tablinks.'</li>' ;

Tab that isn't working (and by not working, I mean not highlighted once clicked);

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'thesite')
{
$vbulletin->options['selectednavtab']='thesite';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="/testvb/information.php">Link1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Events</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">Diary of Events</a></li>
<li><a href="sublink2.php">Forthcoming Everton Events</a></li>
<li><a href="sublink3.php">Official Facebook Events Group</a></li>
</ul>
</li>
<li><a href="link2.php">Supporter Clubs</a></li>
<li><a href="link3.php">Visitors Guide</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.grandoldteam.com/testvb/newsfeed.php">The Site</a>'.$tablinks.'</li>' ;

:confused:

Thanks very much for this (and your create own page tutorial) Lynne, your work is massively appreciated.

Can I be a pain and ask your advice? I am attempting to include two tabs on my test forum. One works fine, not a problem but the second tab doesn't remain highlighted once clicked. I've read through the thread and fiddled with it for over an hour, any possible chance you could have a look at my code and identify the problem?

:confused:
You have both tabs going to the newsfeed.php page. How is it supposed to know which tab to highlight when the link is the same? It doesn't know which tab you are clicking on to get there. It decides which to highlight based on your condition which is based on THIS_SCRIPT.

Thanks but still having the same problem (http://www.grandoldteam.com/testvb/forum.php) Lynne after changing the bottom link to a unique page.

Thanks but still having the same problem (http://www.grandoldteam.com/testvb/forum.php) Lynne after changing the bottom link to a unique page.
Well, this is you condition in the second plugin:
if (THIS_SCRIPT == 'thesite')
Did you define THIS_SCRIPT in your page? If you didn't define it there, then it will default to the Forum link.

Well, this is you condition in the second plugin:
if (THIS_SCRIPT == 'thesite')
Did you define THIS_SCRIPT in your page? If you didn't define it there, then it will default to the Forum link.

Doh! Of course I didn't, because that would have been too easy.

Thanks Lynne. All sorted now! :)

I just tried adding a new tab in navtab. I have suceeded adding a tab.
But I still have questions to get it working fully. So please help me out.

I added a new tab called 'product' in navtab.
Q1) Do I have to create a page for product as a php file?
Q2) if so where do I upload the php file? which folder?
Q3) After making the file and link it with the 'product'tab, would submenus show up? Currently 'product' tab is linked to index.php for testing purpose. Therefore it highlights 'home' tab and shows home's submenues.

I just tried adding a new tab in navtab. I have suceeded adding a tab.
But I still have questions to get it working fully. So please help me out.

I added a new tab called 'product' in navtab.
Q1) Do I have to create a page for product as a php file?
Q2) if so where do I upload the php file? which folder?
Q3) After making the file and link it with the 'product'tab, would submenus show up? Currently 'product' tab is linked to index.php for testing purpose. Therefore it highlights 'home' tab and shows home's submenues.
1) No, but the page should exist or why link to it?
2) Wherever you said it was supposed to link to in your tab (same folder as other vbulletin files?)
3) Only if you write the condition correct about when to show the submenus and make the tab 'selected'. In my example, the condition is based about THIS_SCRIPT, so if you define THIS_SCRIPT in the products.php page, then use it in your condition like in the example.

Hey Lynne,
First off let me say that this guide has been incredibly helpful for me. I love being able to customize the tabs, and your instructions were easy enough to follow.

I have a good amount of experience with VB, but I have hit a snag. I did some reading in this thread, some searching of this thread (as well as google) and still have not been able to find a solution to my problem.

I am using VB 4.0.2 Suite with the CMS as the homepage. I have a number of different "Sections" set up in my CMS, and I would like each section to have its own button on the NavBar Tabs. This causes me problems because when I set it up so that a section (lets call it "Events") has its own button, even though I have set a custom THIS_SCRIPT setting for the plugin, the home button is still "selected" on the navbar. I believe this is because the "Events" page still is generated from the content.php file, and this is causing the problem with the THIS_SCRIPT setting, as they would be the same. Is my thinking correct?

If so, is there anything I can do to work around this?

Thanks in advance!

The conditions for showing the HOME tab to be 'selected' are in the plugin for the Home tab - Navbar: Insert CMS Navbar Entry. You would have to rewrite that condition so the tab is not selected when you want one of your other tabs to be selected.

Is there an easier way to do so or maybe a guide I could follow? I dont have much experience with vBulletin Conditionals.

Thanks

This is great however the only issue I have found is the height of the navbar isn't consistent.

Here is what I mean:
113573

This is my plugin code:
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'adv_index')
{
$vbulletin->options['selectednavtab']='Home';
$tabselected = ' class="selected"';
$tablinks = '';

}
$template_hook['navtab_start'] .= '<li'.$tabselected.'><a class="navtab" href="../index.php">Home</a>'.$tablinks.'</li>' ;

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'online')
{
$vbulletin->options['selectednavtab']='Online';
$tabselected2 = ' class="selected"';
$tablinks2 = ' <ul class="floatcontainer">
<li><a href="link1.php">Online</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected2.'><a class="navtab" href="../forum/online.php">Online</a>'.$tablinks2.'</li>' ;

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'calendar')
{
$vbulletin->options['selectednavtab']='Events';
$tabselected3 = ' class="selected"';
$tablinks3 = ' <ul class="floatcontainer">
<li><a href="link1.php">Events</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected3.'><a class="navtab" href="../forum/calendar.php">Events</a>'.$tablinks3.'</li>' ;

The other thing is the above code seems very inefficient to me - I will probably have another few more tabs as well so it would need to be stepping through a lot just to create the tabs and sub menus or in the scheme of things going through this code each time a page is displayed is not worth worring about - any thoughts?

This is great however the only issue I have found is the height of the navbar isn't consistent.

Here is what I mean:
113573

The other thing is the above code seems very inefficient to me - I will probably have another few more tabs as well so it would need to be stepping through a lot just to create the tabs and sub menus or in the scheme of things going through this code each time a page is displayed is not worth worring about - any thoughts?
You will have to look at your code using something like firebug to see why it is doing what it is doing. I can't tell from the image.

As for it being inefficient, I wrote this just to add a single tab. I suppose it could be modified slightly to make it more efficient when you add several tabs, but I really don't know that it would make a huge impact.

Thanks Lynn - have worked out that if you don't have a sub menu under a tab you will get that inconsistency in the navbar height so I have added a sub menu like "About", "Site Rules" etc and that fixed it.

Any suggestions on how I could make it more efficient so I can have tabs across the page - thanks!

unfortunately this just doesn't work for me. i added the plugin with the exact things you posted in your entry post (just to see, if it works) and it doesn't even generate a navtab, even though the plugin is activated. I'm on vB 4.0.2 PL1

EDIT: okay nvm. i had to enable the plugins globally. :D

I've got this working except for the selected tab being highlighted as "on". What I need now is to figure out how to specify each of these specific articles as the condition. I have added three tabs: Raid Teams, Roster and Recruitment.

Each of these tabs points to a specific article, meaning content.php?r=articlename.
How can I specify that as my condition? Since they are articles, I can't use the THIS SCRIPT since it's content.php?r=articlename?

I tried article titles (since that worked for my content section vb:if code, but it didn't work for this.... if ("$title == 'Raid Teams'")

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

Hello Lynne,

You have helped me out with a lot of problems on Vbulletin.com yesterday and today. I am hoping you can help me out with something here.

There are a couple of things I am not sure about. I did what you said in your first post. The Nav Link tab appeared. I changed it to Home and changed aswell the link. It worked perfectly. Thank you for that! You are helping out many people!

- Do I need to add the same plugin for each tab I need to create? Or do you edit it in the code?

- Is there a way to organize the tabs? I only got the forum installed and not the CMS. My first tab is Forum, than What's new and than the Nav Link (now renamed it to Home). When I edit the code and the new tab is hooked to navbar_start instead of navbar_end. Than it shows before Forum and What's new. That is good. But I need to create 4 more tabs. How can I organize those if they appear after navbar_end?

I've got this working except for the selected tab being highlighted as "on". What I need now is to figure out how to specify each of these specific articles as the condition. I have added three tabs: Raid Teams, Roster and Recruitment.

Each of these tabs points to a specific article, meaning content.php?r=articlename.
How can I specify that as my condition? Since they are articles, I can't use the THIS SCRIPT since it's content.php?r=articlename?

I tried article titles (since that worked for my content section vb:if code, but it didn't work for this.... if ("$title == 'Raid Teams'")

I *think* you can use the nodeid variable. Edwin has talked about it over on vb.com in relation to articles and sections. So, you may want to look into that. But, you will probably also have to dive into the code that decides when the Home page is the selected page in order to only select the Home page as selected when those $nodeids are not true.


- Do I need to add the same plugin for each tab I need to create? Or do you edit it in the code?

- Is there a way to organize the tabs? I only got the forum installed and not the CMS. My first tab is Forum, than What's new and than the Nav Link (now renamed it to Home). When I edit the code and the new tab is hooked to navbar_start instead of navbar_end. Than it shows before Forum and What's new. That is good. But I need to create 4 more tabs. How can I organize those if they appear after navbar_end?
You can put all the tabs into one plugin. If they are all using the same $template_hook, then put them in the order you want them to appear. I think someone posted some code in the last couple pages showing their plugin for a couple of tabs.

For the php condition in CMS you should be able to use
if (in_array($this->content->getNodeId(), array(1,2,3)))for line 3 of Lynnes code, where 1,2,3 is a comma delimited list of the nodeids of the article/sections that you want to show your tab as highlighted on.

Now, if you have your custom tab highlighted, you don't want the Home Tab highlighted at the same time. To prevent Home Tab being selected, edit Template vbcms_navbar_link
<vb:if condition="$vboptions['selectednavtab'] == 'vbcms' AND !in_array($nodeid, array(1,2,3))">Add the red code to the condition in the first line of the template and replace 1,2,3 with a comma delimited list of the nodeids that you don't want to show the Home-Tab selected.

Thank you, cellarius! I knew what had to be done, just not exactly how to do it. Thanks for posting that. :)

Hello,

i created it, but i dont get submenu?
Look here:
http://project-mp.com/index.php

Titel in navbar is "Webradio"

Hi Lynne great tutorial I was able to get it to work fine on some tabs, but I am having problems when I have "conflicting" items.

For example, I am trying to create a separate tab for the "usercp.php" page called "My Forums", however I guess the usercp.php page is already tied to the main Forum tab. So when I click the new tab I created, I get both tabs highlighted and the submenus overlap.

I am not certain how to make the new tab "unique" if that makes sense. Any help would be appreciated thank you.

Hello,

i created it, but i dont get submenu?
Look here:
http://project-mp.com/index.php

Titel in navbar is "Webradio"
What is the condition you used to show the sub-forum? It needs to be valid, otherwise the Forum tab is the default tab.

Hi Lynne great tutorial I was able to get it to work fine on some tabs, but I am having problems when I have "conflicting" items.

For example, I am trying to create a separate tab for the "usercp.php" page called "My Forums", however I guess the usercp.php page is already tied to the main Forum tab. So when I click the new tab I created, I get both tabs highlighted and the submenus overlap.

I am not certain how to make the new tab "unique" if that makes sense. Any help would be appreciated thank you.
You may have to edit the navbar template where the condition for showing the submenu for the usercp is. This is in the navbar template:
<vb:elseif condition="$vboptions['selectednavtab']=='usercp'" />

So, you'll need to change that to say "if selectednavtab is usercp but NOT whatever-your-condition-is"

What is the condition you used to show the sub-forum? It needs to be valid, otherwise the Forum tab is the default tab.


You may have to edit the navbar template where the condition for showing the submenu for the usercp is. This is in the navbar template:
<vb:elseif condition="$vboptions['selectednavtab']=='usercp'" />

So, you'll need to change that to say "if selectednavtab is usercp but NOT whatever-your-condition-is"

I dont understand, my english is not so good. What i must do?

I don't know how else to explain it. In the navbar code, there is a submenu set to be displayed when you are in the usercp. You are trying to create a different one to show. The two conditions cannot exist at the same time. You need to have UNIQUE conditions or only one can display.

How do we make this new tab have a drop down menu?

How do we make this new tab have a drop down menu?
In the code in the first post, one of the submenu items is a dropdown. If you are talking about the navtab itself being a dropdown, someone else wrote an article for that (I think it was Shelby).

OK... I'm stuck here. I get an error when i activate the code...

arse error: syntax error, unexpected T_STRING in /public_html/forums/includes/class_bootstrap.php(399) : eval()'d code on line 61

$tabselected = '';
$tablinks = '';
if (in_array($foruminfo['forumid'], array(24,36,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66 ,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,9 3,96,101,103,105,127,129,130,131)))
{
$vbulletin->options['selectednavtab']='racing_news';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Late Model News</a>
<ul class="popupbody popuphover">
<li><a href="http://www.mysite.com/forums/forumdisplay.php?88-General-Other-Dirt-Late-Model-News">General/Other Late Model News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?55-Crate-Late-Model-Series">Crate Late Model News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?47-Lucas-Oil-Late-Model-Series">Lucas Oil Late Model Series News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?48-Mid-America-Racing-Series-(MARS)">MARS DIRTcar Series News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?52-MLRA-TORA-SUPR-AMP-MSRA-amp-Other-Series">MLRA/MSRA/SUPR & Other Series News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?49-United-Midwestern-Promoters-(UMP)">U.M.P. DIRTcar News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?46-World-of-Outlaw-Late-Model-Series">World of Outlaw Late Model Series News</a></li>
</ul>
</li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Sprint Car News</a>
<ul class="popupbody popuphover">
<li><a href="http://www.mysite.com/forums/forumdisplay.php?89-General-Other-Sprint-Midget-News">General/Other Sprint-Midget News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?134-American-Sprint-Car-Series-(ASCS)">American Sprint Car Series (ASCS) News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?77-All-Star-Sprint-Series">All Star Sprint Series News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?78-O-Reilly-POWRi-Series">O'Reilly POWRi Series News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?92-USAC">USAC News</a></li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?75-World-of-Outlaws-Sprint-Car-Series">World of Outlaws Sprint Car Series News</a></li>
</ul>
</li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Race Track News</a>
<ul class="popupbody popuphover">
<li><a href="http://www.mysite.com/forums/forumdisplay.php?53-Belle-Clair-Speedway">Belle-Clair Speedway</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="http://www.mysite.com/forums/forumdisplay.php?36-Race-Team-News">Race Teams News</a></li>
</ul> ';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/forums/forumdisplay.php?24-Racing-News">Racing News</a>'.$tablinks.'</li>' ;

--------------- Added 1268705656 at 1268705656 ---------------

Found my issue.. One of my links had a ' in the link description.

Excellent guide, thanks Lynne. Finally making my first venture into making new pages in vB4 and this helped me a lot. :)

Does anyone know of a guide on how to recreate the quick links including drop downs in the Navbar?

All you need to create a dropdown is there in the code from first post in this thread:
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>

Right see all people really want is a button on the navbar saying what's going on. What would I have to do for that?

Right see all people really want is a button on the navbar saying what's going on. What would I have to do for that?

There are several different articles/mods for the navtabs and submenu. If all you want is another button on the submenu, then you should go to Allan's tutorial. If all you want is a navtab, then there are modifications to do that.

I've used portions of this article which worked great through 4.0.2pl2.
Now with pl4 I don't see the selections of the link until I hover over it.

Problem with Firefox Mac and PC.
Anyone else having this problem?

SOLVED: Reverted template.

And what if I want to link into section like:

content.php?r=5
instead of clean php page?

Ok chaps...please please please do not bite my head off.

I understand the basics of this and Lynne thank you for producing this guide.

What im not understanding is how to link offsite.

For example our site has a number of facebook games...we produce them (dont hate me).

I want to be able to link to those sites.

Now currently I use: vBH - Add new tabs 1.2 1.2 This plugin adds new tabs to the main navbar

this is of course fine and dandy...however till you get to the issue of screen size. People with smaller screens end up with squished nav buttons.

example http://forum.clipwiregames.com/forum.php if u use half screen u will notice all the additional tabs get squished.

Now i did a couple of test tabs using Lynnes setup and they did not, it worked perfect.

Thus my only issue is understanding how to make the links not internal php links but external.

thanks ...hopefully i made myself semi clear.

And what if I want to link into section like:

content.php?r=5
instead of clean php page?
Why couldn't you link to that?

Ok chaps...please please please do not bite my head off.

I understand the basics of this and Lynne thank you for producing this guide.

What im not understanding is how to link offsite.

For example our site has a number of facebook games...we produce them (dont hate me).

I want to be able to link to those sites.

Now currently I use: vBH - Add new tabs 1.2 1.2 This plugin adds new tabs to the main navbar

this is of course fine and dandy...however till you get to the issue of screen size. People with smaller screens end up with squished nav buttons.

example http://forum.clipwiregames.com/forum.php if u use half screen u will notice all the additional tabs get squished.

Now i did a couple of test tabs using Lynnes setup and they did not, it worked perfect.

Thus my only issue is understanding how to make the links not internal php links but external.

thanks ...hopefully i made myself semi clear.
Instead of:
<a href="/page.php">A page on your site</a>

do:
<a href="http://www.anothersite.com/page">A page on another site</a>

Why couldn't you link to that?
I did it. but the problem is that when I press in this button the navbar still selects the Forum tab, because I can't do a condition in this section:

if (THIS_SCRIPT == 'yourpage')
{

$vbulletin->options['selectednavtab']='unique_name';
$tabselected = ' class="selected"';

}

If you're linking to a site outsiede vB, it does not make much sense to show a tab as highlighted. You simply don't need that part.

If you're linking to a site outsiede vB, it does not make much sense to show a tab as highlighted. You simply don't need that part.
I linking to section in vBulletin!

Sorry, I mixed you up with jacx. Anyway, I posted the solution for your problem on the previous page of this thread, #199

Sorry, I mixed you up with jacx. Anyway, I posted the solution for your problem on the previous page of this thread, #199
I got this error:

Fatal error: Call to a member function getNodeId() on a non-object in /home/*username*/public_html/vb/includes/class_bootstrap.php(399) : eval()'d code on line 3

when I used this code.

this is my code:

$tabselected = '';
$tablinks = '';
if (in_array($this->content->getNodeId(), 5))
{
$vbulletin->options['selectednavtab']='content.php?r=5';
$tabselected = ' class="selected"';
$tablinks = '';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?r=5">News</a>'.$tablinks.'</li>' ;

Why couldn't you link to that?


Instead of:
<a href="/page.php">A page on your site</a>

do:
<a href="http://www.anothersite.com/page">A page on another site</a>


when i tried that it took me to http://mysite.com/link.php

Edit...im trying to post the code i used and keep getting "Bad Request" when i do it..anyone know what im doing wrong so i can post what i had entered?

Hi Lynne,

If I want only the user with id=1 to see the link. What I have to do?

Thanks.

when i tried that it took me to http://mysite.com/link.php

Then you have a setting or modification that is doing that. If you have the link written as going to http://www.somesite.com/link.php then it should go there, not to your site.
Hi Lynne,

If I want only the user with id=1 to see the link. What I have to do?

Thanks.
This was covered, I think, on page 2 or 3.

I created a PHP file with nothing in it but the following:

<?php
define('THIS_SCRIPT', 'locallinks');
?>

My plugin script has the following:

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

At the bottom of the plugin is:

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="/index.php?pageid=locallinks">Test Link</a>'.$tablinks.'</li>' ;


When I click on my new tab, it highlights the Forum tab and shows all the regular stuff found under Forum (New Posts, Private Messages, FAQ, etc).

Any help is appreciated.

This was covered, I think, on page 2 or 3.

Thanks, but that is cover for usergroup.

I create new NavTab as follow, and I want only me to see the Chat Admin. Please help.
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'chat')
{
$vbulletin->options['selectednavtab']='chat';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="chat/admin.php" target="_blank">Chat Admin</a></li></ul> ';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="chat.php">Chat</a>'.$tablinks.'</li>' ;

I created a PHP file with nothing in it but the following:

<?php
define('THIS_SCRIPT', 'locallinks');
?>
According to your code, your page is located at http://yoursite.com/index.php?pageid=locallinks Yet, I'm guessing that is not the link to your actual php page you created above? You you get sent to index.php which is probably forwarded to your forum.php page (check the script) and thus the Forum tab gets highlighted.
Thanks, but that is cover for usergroup.

I create new NavTab as follow, and I want only me to see the Chat Admin. Please help.
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'chat')
{
$vbulletin->options['selectednavtab']='chat';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="chat/admin.php" target="_blank">Chat Admin</a></li></ul> ';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="chat.php">Chat</a>'.$tablinks.'</li>' ;
Instead of this sort of condition:
if (is_member_of($vbulletin->userinfo, 5, 6, 7)) You would use this sort of condition:
if ($vbulletin->userinfo['userid'] == 1)
You probably want to wrap that condition around the full contents of the plugin if it is only to show for that userid.

Thank you very much.

Thanks for the reply Lynne...I actually have no clue what I'm doing (is it that obvious?). I just want to have a new link called Local Links that when clicked will show 4 new sublinks with their own links. On the new tab I really don't need it to display any content when it's clicked, just the links. Is this the right mod for me? Thanks again.

Thanks for the reply Lynne...I actually have no clue what I'm doing (is it that obvious?). I just want to have a new link called Local Links that when clicked will show 4 new sublinks with their own links. On the new tab I really don't need it to display any content when it's clicked, just the links. Is this the right mod for me? Thanks again.
It would be the correct mod, however you need to define exactly *when* those sub-menus are supposed to show. If you can't define that, then your sub-menus will never show.

Lynne, this is brilliant! I upgraded my forums (drzforums.com) last night, and ran into a few pain-points. Using your instructions, I created the navigation tabs that I would like, reusing all of the sub-menu links from the "Forum" tab. Now, I'm left with one more question, which I am having difficulty finding through search.

There is one "Quick Link" that refers to a javascript code bite. How do I program "Open Contacts Popup?" Can you point me in the right direction?

Thank you for the trouble you went through to document the tab creation process!

Heh... I guess I'm going to have to setup some conditionals for several of the sub-menu items. :) (I just viewed my site as a guest.)

There is one "Quick Link" that refers to a javascript code bite. How do I program "Open Contacts Popup?" Can you point me in the right direction?
I'm not sure what you mean by How do you program it.

THANKS Lynne! Very helpful!

It would be the correct mod, however you need to define exactly *when* those sub-menus are supposed to show. If you can't define that, then your sub-menus will never show.

Gotcha...I only want them to show when I click the tab that they belong to. In a perfect world, when the user clicks a tab called Local Links, they will see 3 submenus appear below: 1) EG, 2) Laguna, 3) Sac. Then each of those will have their own URL or additional sub-menus to offsite pages or whatever. The "Local Links" page that opens when the user clicks the tab doesn't need any data if that's possible. Or if it must contain text, then I can just enter something describing the page to the user. Does that make any sense and is it possible? Thank you.

Gotcha...I only want them to show when I click the tab that they belong to. In a perfect world, when the user clicks a tab called Local Links, they will see 3 submenus appear below: 1) EG, 2) Laguna, 3) Sac. Then each of those will have their own URL or additional sub-menus to offsite pages or whatever. The "Local Links" page that opens when the user clicks the tab doesn't need any data if that's possible. Or if it must contain text, then I can just enter something describing the page to the user. Does that make any sense and is it possible? Thank you.
Ok, so write that as a condition now. For other vbulletin pages, THIS_SCRIPT is defined at the top - so if you only want something to happen on the showthread page, the condition is THIS_SCRIPT == 'showthread'... so, what defines your page? Have you defined THIS_SCRIPT in it? If so, just use that as the condition in the plugin.

Do you know if it's possible to use vbAdvanced to create a BB Code page and have it work with this mod then? If memory serves the url looks something like sitename.com/index.php?pageid=pagename

what would you use for THIS_SCRIPT in that situation?

SOLVED:

I used:

if (THIS_SCRIPT == 'adv_index' AND $pages['name'] == 'testpage')

I want to create a tab for a specific section in the CMS. Is there a way to get the section name in the PHP code?

I can see the section name in the navbar so maby I can get the navbar text and use this for a compare?

I was thinking something like


if (THIS_SCRIPT == 'vbcms')
{
if (sectionname =='My Section')
{
$vbulletin->options['selectednavtab']='unique_name';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Drop Down</a>
<ul class="popupbody popuphover">
<li><a href="sublink1.php">SubLink 1</a></li>
<li><a href="sublink2.php">SubLink 2</a></li>
<li><a href="sublink3.php">SubLink 3</a></li>
</ul>
</li>
<li><a href="link2.php">Link 2</a></li>
<li><a href="link3.php">Link 3</a></li>
</ul> ';


}
}





Please can anyone help? I have searched for this the whole day

I want to create a tab for a specific section in the CMS. Is there a way to get the section name in the PHP code?

I can see the section name in the navbar so maby I can get the navbar text and use this for a compare?

I was thinking something like

Please can anyone help? I have searched for this the whole day
You didn't put anything in your code that showed what variable names you have tried for the section name.

You didn't put anything in your code that showed what variable names you have tried for the section name.

No that was my question :) what variable names can I use to get a section?

Sorry if I am not being clear, I was hoping someone new a way to check for a section name in the php code.

This was very useful, thanks much.

Just a little thing I noticed while searching for something related to this tutorial...

** link removed **

Seems to be very familiar... word for word with no credit given in fact... how rude!

Sorry, we don't like links to that site. However, I'm not surprised to see this there - that is what they do - copy, copy, copy, with no credit and no permission.

Ok I tried Cellarius' change for using with the CMS. Here is my code:
if (in_array($this->content->getNodeId(), array(147,152,153)))

Error:
Fatal error: Call to a member function getNodeId() on a non-object in includes/class_bootstrap.php(399) : eval()'d code on line 3

Cellarius' change doesn't work in 4.0.3 any longer. I haven't looked into it to see what works now.

Seems like getNodeId is deprecated in 4.0.3?

I'll do some testing and playing with, if I find a solution I will post it for all to use.

Try using $_GET to detect the section.

you can using this example:

$tabselected = '';
$tablinks = '';

if (($_GET['r'] == 10) && (THIS_SCRIPT == 'vbcms'))
{
$vbulletin->options['selectednavtab']='content.php?r=10';
$tabselected = ' class="selected"';
$tablinks = '';

}

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?r=10">Tab Name</a>'.$tablinks.'</li>' ;

Try using $_GET to detect the section.

Oh yeah, I forgot about that one. Thanks.

Try using $_GET to detect the section.
....

Yes this will help if you have selected the section main page, but it still wont work if you select an article inside a section becaurse "r" then will relate to the article and not the section.

I have the same problem, and got a good answer at vbulletin.com (although I dident get the solution to work) Here is the link: http://www.vbulletin.com/forum/showthread.php?348708-Get-CMS-section-in-plugin-code&p=1964854

Yes this will help if you have selected the section main page, but it still wont work if you select an article inside a section becaurse "r" then will relate to the article and not the section.

I have the same problem, and got a good answer at vbulletin.com (although I dident get the solution to work) Here is the link: http://www.vbulletin.com/forum/showthread.php?348708-Get-CMS-section-in-plugin-code&p=1964854
I know it.

But for now, It's better than nothing ;)










privacy (GDPR)