vBulletin ModsThe Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=226914 |
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.)
Things to take note of:
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.
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.
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 |
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.
Thanks again for all your help lately. Don't know what VB would do without ya :p |
Quote:
Quote:
In this case, your condition would be:
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.
|
Quote:
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).
|
Quote:
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. |
Quote:
|
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?66...the-vB4-Navbar
|
1 Attachment(s)
Quote:
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:
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. |
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 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. |
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...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. |
Quote:
|
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
|
Quote:
|
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...
I also want to link to external links, can I do this or am I better doing it via the bottom code
Thanks:confused: |
Please www.arenatr.com look top navbar link (Forum categories)
|
Quote:
That isn't tested, but it should work. And, there is no reason you can't make external links. Quote:
|
Quote:
Where do you get that from? |
When you create your own page, 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 :) |
Quote:
|
Quote:
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 |
Quote:
|
Lynne states where the code has to go - into a plugin at:
Quote:
|
Quote:
Quote:
Quote:
|
Thanks Lynne,
http://www.bizimforumlar.com/vbtest/test.php |
Quote:
|
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"
|
Quote:
|
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.
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:
|
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?
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. :) |
Quote:
What about if I want to add two tabs? with one unblocked and the other one set to usergroups. Would it be like this:
|
Quote:
|
Quote:
-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.
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?
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? |
Quote:
|
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
|
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
(I only wish admins/mods to be able to see a certain link) but it completely breaks this plugin, you get a Quote:
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/showp...6&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:
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:
|
Quote:
Quote:
Thanks again. |
Quote:
|
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 |
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 |
Quote:
|
I made a new thread about this. If you can help me please go here:
http://www.vbulletin.org/forum/showt...54#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, 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):
|
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?
|
Quote:
with
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:
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. |
Quote:
|
Quote:
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:
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:
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?
|
Quote:
|
1 Attachment(s)
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.
|
Quote:
|
on my RC2 the function selected doesn't work....
|
Quote:
|
This is what i use
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 |
Quote:
Quote:
|
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. |
Quote:
|
Quote:
You will NEED to define THIS_SCRIPT at the top of all those pages!!!!
Quote:
|
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.
--------------- Added 18 Dec 2009 at 07:57 --------------- Nevermind...lol figured it out. If anyone else needs this the code is:
|
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. |
Quote:
Maria |
Quote:
Actually I had to Quote:
|
Thank you Lynne, this is extremely helpful :)
|
All times are GMT. The time now is 08:07. |
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.