Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[HOW TO - vB4] Create a New Tab in the navbar
Lynne
Join Date: Sep 2004
Posts: 41,215

California/Idaho
by Lynne Lynne is offline 27 Oct 2009
Rating: (3 votes - 3.67 average)

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.




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
Attached Images
File Type: png vb4_nav_links.png (21.8 KB, 17116 views)

Last edited by Lynne; 16 Jan 2011 at 19:59..
Views: 92708
Reply With Quote
Comments
  #2  
Old 29 Oct 2009, 21:08
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
Thanks, Lynne! Good work, will come in handy!
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #3  
Old 14 Nov 2009, 21:14
Parture Parture is offline
 
Join Date: Aug 2005
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.

Last edited by Parture; 14 Nov 2009 at 21:32.
Reply With Quote
  #4  
Old 14 Nov 2009, 21:18
skylab's Avatar
skylab skylab is offline
 
Join Date: Feb 2009
Real name: Mike
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
__________________
http://www.artoftravelblogging.com - A Travel Blogging Community
Reply With Quote
  #5  
Old 14 Nov 2009, 21:34
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Originally Posted by Parture View Post
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.

Originally Posted by skylab View Post
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
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.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)

Last edited by Lynne; 14 Nov 2009 at 21:40.
Reply With Quote
  #6  
Old 14 Nov 2009, 21:41
Parture Parture is offline
 
Join Date: Aug 2005
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.
Reply With Quote
  #7  
Old 14 Nov 2009, 22:07
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
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".
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #8  
Old 14 Nov 2009, 22:41
Parture Parture is offline
 
Join Date: Aug 2005
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.
Reply With Quote
  #9  
Old 14 Nov 2009, 22:51
JimLink JimLink is offline
 
Join Date: Aug 2005
Very useful indeed. Thank you.
Reply With Quote
  #10  
Old 14 Nov 2009, 23:30
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Originally Posted by Parture View Post
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
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #11  
Old 14 Nov 2009, 23:58
Parture Parture is offline
 
Join Date: Aug 2005
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.
Reply With Quote
  #12  
Old 15 Nov 2009, 18:04
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
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).
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #13  
Old 15 Nov 2009, 18:10
Parture Parture is offline
 
Join Date: Aug 2005
Originally Posted by Lynne View Post
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.

Last edited by Parture; 15 Nov 2009 at 18:15.
Reply With Quote
  #14  
Old 15 Nov 2009, 18:15
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Originally Posted by Parture View Post
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.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #15  
Old 15 Nov 2009, 18:31
Parture Parture is offline
 
Join Date: Aug 2005
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.

Last edited by Parture; 15 Nov 2009 at 18:47.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


New To Site? Need Help?

All times are GMT. The time now is 14:03.

Layout Options | Width: Wide Color: