vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=226914

[HOW TO - vB4] Create a New Tab in the navbar
by Lynne
27 Oct 2009 21:02

1 Attachment(s)
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/exte...011/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.)


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Things to take note of:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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)



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

Other related articles of possible interest:
[HOW TO - vB4] Remove the vB Default Navtabs
[HOW TO - vB4] Create your own vBulletin page

cellarius 29 Oct 2009 21:08

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

Parture 14 Nov 2009 21:14

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.

skylab 14 Nov 2009 21:18

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Thanks again for all your help lately. Don't know what VB would do without ya :p

Lynne 14 Nov 2009 21:34

Quote:

Originally Posted by Parture (Post 1914259)
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.

Quote:

Originally Posted by skylab (Post 1914264)
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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In this case, your condition would be:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The condition does NOT have to be based on THIS_SCRIPT, but it DOES have to be UNIQUE to that tab.

Parture 14 Nov 2009 21:41

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.

Lynne 14 Nov 2009 22:07

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".

Parture 14 Nov 2009 22:41

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.

JimLink 14 Nov 2009 22:51

Very useful indeed. Thank you.

Lynne 14 Nov 2009 23:30

Quote:

Originally Posted by Parture (Post 1914308)
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

Parture 14 Nov 2009 23:58

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.

Lynne 15 Nov 2009 18:04

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).

Parture 15 Nov 2009 18:10

Quote:

Originally Posted by Lynne (Post 1914692)
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.

Lynne 15 Nov 2009 18:15

Quote:

Originally Posted by Parture (Post 1914697)
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.

Parture 15 Nov 2009 18:31

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.


All times are GMT. The time now is 20:24.

Powered by vBulletin® Version 3.8.12
Copyright © 2019, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.