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 22: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 22:08

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

Parture 14 Nov 2009 22: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 22: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 22: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 22: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 23: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 23: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 23:51

Very useful indeed. Thank you.

Lynne 15 Nov 2009 00: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 15 Nov 2009 00: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 19: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 19: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 19: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 19: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.

ragtek 15 Nov 2009 20:17

There's also a other way adding own tabs: http://vbcodex.com/showthread.php?66...the-vB4-Navbar

Lynne 15 Nov 2009 20:18

1 Attachment(s)
Quote:

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

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

As for my "unique_name", I just used "torrents".

This is the result on my site:
Attachment 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.

Lionel 15 Nov 2009 21:00

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

speedracer68 17 Nov 2009 16:28

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 17 Nov 2009 at 16:44 ---------------

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 17 Nov 2009 at 16:54 ---------------

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.

Lynne 17 Nov 2009 17:14

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.

speedracer68 17 Nov 2009 17:20

Please visit http://www.pro-touring.com/forum_new...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.

Lynne 17 Nov 2009 17:47

Quote:

Originally Posted by speedracer68 (Post 1915970)
Please visit http://www.pro-touring.com/forum_new...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

speedracer68 17 Nov 2009 17:54

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.

arena 17 Nov 2009 20:01

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

Lynne 17 Nov 2009 20:25

Quote:

Originally Posted by arena (Post 1916075)
How do I show links forum categories navbar? Same as forum blog cms

I don't understand what you mean.

Bounce 17 Nov 2009 20:46

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


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

I also want to link to external links, can I do this or am I better doing it via the bottom code

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

Thanks:confused:

arena 17 Nov 2009 20:47

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

Lynne 17 Nov 2009 21:28

Quote:

Originally Posted by hIBEES (Post 1916110)
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...


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

I also want to link to external links, can I do this or am I better doing it via the bottom code

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

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:

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

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

Quote:

Originally Posted by arena (Post 1916111)
Please 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.

Bounce 17 Nov 2009 21:40

Quote:

Originally Posted by Lynne (Post 1916136)
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:

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

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

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

Where do you get that from?

ragtek 17 Nov 2009 21:46

When you create your own page, you have to define this_script;)

Bounce 17 Nov 2009 21:47

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:

BlackJacket 17 Nov 2009 22:54

Sorry, but where do i add this code to?

Thanks :)

EidolonAH 18 Nov 2009 00:20

Quote:

Originally Posted by NittoMOD (Post 1916192)
Sorry, but where do i add this code to?

Thanks :)

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

DesignWerks 18 Nov 2009 00:37

Quote:

Originally Posted by Lynne (Post 1914740)
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:

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

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

taffy056 18 Nov 2009 00:47

Quote:

Originally Posted by NittoMOD (Post 1916192)
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

cellarius 18 Nov 2009 01:04

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

Originally Posted by Lynne
hook location - global_state_check

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

Lynne 18 Nov 2009 01:09

Quote:

Originally Posted by hIBEES (Post 1916149)
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.
Quote:

Originally Posted by NittoMOD (Post 1916192)
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.
Quote:

Originally Posted by DesignWerks (Post 1916234)
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 ?).

zbahadir 18 Nov 2009 01:50

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

EidolonAH 18 Nov 2009 02:12

Quote:

Originally Posted by cellarius (Post 1916266)
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.

cellarius 18 Nov 2009 02:21

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

Lynne 18 Nov 2009 02:38

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.

Lionel 18 Nov 2009 08:16

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

EidolonAH 18 Nov 2009 08:42

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.

cellarius 18 Nov 2009 09:42

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

Dave-ahfb 18 Nov 2009 15:24

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"

Lynne 18 Nov 2009 15:36

Quote:

Originally Posted by Dave-ahfb (Post 1916579)
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.

crazyace 18 Nov 2009 17:01

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.


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

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 18 Nov 2009 at 17:07 ---------------

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:

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


Lynne 18 Nov 2009 17:42

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.

crazyace 18 Nov 2009 20:13

Ok so something like this?


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

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.

Lynne 18 Nov 2009 20:54

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

Hello Kallell! Now I recognize you. :)

crazyace 18 Nov 2009 21:57

Quote:

Originally Posted by Lynne (Post 1916773)
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:


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


Lynne 19 Nov 2009 00:45

Quote:

Originally Posted by crazyace (Post 1916824)
:)

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.

ngkong 21 Nov 2009 11:26

Quote:

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

Tab to external link?
by j.steensen
22 Nov 2009 14:44

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


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

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

Lynne 22 Nov 2009 16:30

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?

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

When you say it doesn't seem to do anything, are you seeing a tab at all? Do you have the plugin active?

j.steensen 22 Nov 2009 16:56

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

Its always the simplest solution.

Appreciate it!

shadowedsoul 25 Nov 2009 21:46

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?

Lynne 25 Nov 2009 22:11

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

Eric Anderson 26 Nov 2009 10:26

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 26 Nov 2009 15:43

Quote:

Originally Posted by Eric Anderson (Post 1921090)
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).

Eric Anderson 26 Nov 2009 18:50

1 Attachment(s)
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

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


Lynne 26 Nov 2009 18:53

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.

Anseur 30 Nov 2009 22:33

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

I tried wrapping certain links under the custom tab in the


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

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

but it completely breaks this plugin, you get a
Quote:

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.

Lynne 30 Nov 2009 22:50

This post shows how to use conditions to add the links - http://www.vbulletin.org/forum/showp...6&postcount=28 See if that helps.

Anseur 01 Dec 2009 10:15

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:


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

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.

Lynne 01 Dec 2009 16:34

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:

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


Anseur 01 Dec 2009 17:18

Quote:

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

Quote:

Originally Posted by Lynne (Post 1923559)
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:

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

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.

Lynne 01 Dec 2009 17:27

Quote:

Originally Posted by Anseur (Post 1923575)
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.

oooh em geee 02 Dec 2009 23:07

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 02 Dec 2009 at 23:13 ---------------

NVM fixed it

oooh em geee 02 Dec 2009 23:59

2 Attachment(s)
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

Lynne 03 Dec 2009 00:40

Quote:

Originally Posted by oooh em geee (Post 1924343)
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.)

oooh em geee 03 Dec 2009 00:42

I made a new thread about this. If you can help me please go here:
http://www.vbulletin.org/forum/showt...54#post1924354

JarkkoL 04 Dec 2009 21:31

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

Lynne 04 Dec 2009 21:45

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

thunderclap82 08 Dec 2009 01:10

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


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


Lynne 08 Dec 2009 01:59

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?

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


thunderclap82 08 Dec 2009 02:13

Quote:

Originally Posted by Lynne (Post 1927055)
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?

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

So I should replace


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

with


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

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'?

Lynne 08 Dec 2009 03:17

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:

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

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.

thunderclap82 08 Dec 2009 04:28

Quote:

Originally Posted by Lynne (Post 1927082)
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:

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

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.

Lynne 08 Dec 2009 05:03

Quote:

Originally Posted by thunderclap82 (Post 1927098)
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.

thunderclap82 08 Dec 2009 05:15

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:


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

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:


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

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?

Lynne 08 Dec 2009 06:07

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.

thunderclap82 08 Dec 2009 15:59

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?

Lynne 08 Dec 2009 16:04

Quote:

Originally Posted by thunderclap82 (Post 1927271)
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.

Vaupell 15 Dec 2009 11:03

1 Attachment(s)
Lovely it works like a charm, lynne to the rescue ;)

:D

I.am 16 Dec 2009 10:37

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

Lynne 16 Dec 2009 17:33

Quote:

Originally Posted by I.am (Post 1931568)
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.

I.am 16 Dec 2009 20:09

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

Lynne 17 Dec 2009 00:08

Quote:

Originally Posted by I.am (Post 1931800)
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.

I.am 17 Dec 2009 09:14

This is what i use


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

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

AndrewSpearin 17 Dec 2009 13:47

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

Lynne 17 Dec 2009 17:23

Quote:

Originally Posted by I.am (Post 1932101)
This is what i use


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

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

Quote:

Originally Posted by AndrewSpearin (Post 1932180)
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?

AndrewSpearin 17 Dec 2009 20:40

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.

I.am 17 Dec 2009 21:45

Quote:

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

Lynne 17 Dec 2009 23:20

Quote:

Originally Posted by AndrewSpearin (Post 1932428)
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:

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

You will NEED to define THIS_SCRIPT at the top of all those pages!!!!

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

Quote:

Originally Posted by I.am (Post 1932471)
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.

chsmith700 18 Dec 2009 07:52

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.


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

--------------- Added 18 Dec 2009 at 07:57 ---------------

Nevermind...lol figured it out.

If anyone else needs this the code is:

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


AndrewSpearin 18 Dec 2009 16:09

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.

MaryTheG(r)eek 27 Dec 2009 19:57

Quote:

Originally Posted by Lionel (Post 1916454)
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

Lionel 27 Dec 2009 20:18

Quote:

Originally Posted by MicroHellas (Post 1939613)
Try the first without ' ' in phrase. eg ' . $vbphrase[my_phrase] .'

Maria

Hi,

Actually I had to

Quote:

global $vbphrase;

Kinneas 29 Dec 2009 14:17

Thank you Lynne, this is extremely helpful :)


All times are GMT. The time now is 22:47.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, 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.