vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Create a New Tab in the navbar (https://vborg.vbsupport.ru/showthread.php?t=226914)

Lynne 10-26-2009 10:00 PM

[HOW TO - vB4] Create a New Tab in the navbar
 
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://vborg.vbsupport.ru/external/2011/07/104.jpg


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

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

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

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

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

PHP Code:

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


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

Things to take note of:

PHP Code:

if (THIS_SCRIPT == 'yourpage'

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

PHP Code:

$vbulletin->options['selectednavtab']='unique_name'

The 'seletednavtab' must also be a unique name. Again, if you have two tabs with the same 'selectednavtab' name, then both tabs will be highlighted.

PHP Code:

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

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


ragtek also posted an article to do the same thing only using a template with the plugin - [HOW TO - vB4] Create a New Tab in the navbar (with template)



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 10-29-2009 08:08 PM

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

Parture 11-14-2009 08:14 PM

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 11-14-2009 08:18 PM

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.

Code:

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

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

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

Lynne 11-14-2009 08:34 PM

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.

Code:

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

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

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

Same with you.... went do you want this tab to be Active? That is the condition you need to write. Most people want it active when they are on a specific page. At the top of that vbulletin page, THIS-SCRIPT is defined like this:
PHP Code:

define('THIS_SCRIPT''a_page_name'); 

In this case, your condition would be:
PHP Code:

if (THIS_SCRIPT == 'a_page_name'

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

Parture 11-14-2009 08:41 PM

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 11-14-2009 09:07 PM

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 11-14-2009 09:41 PM

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 11-14-2009 09:51 PM

Very useful indeed. Thank you.

Lynne 11-14-2009 10:30 PM

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


All times are GMT. The time now is 02:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01550 seconds
  • Memory Usage 1,798KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete