Back to vBulletin 4 Articles

NAVTAB Combo Drop-Menu with Sub-Items
by cory_booth 14 Jan 2010

I have seen several hack to add a NAVTAB menu item (we are talking about the main links).
However, I had not ran across anything that would do exactly what I wanted.

Here is what this does.
Say you have a few pages you want a drop-down link (from the NAVTAB).
For example, I have an add-on gallery.
I wanted a single NAVTAB button called "GALLERY" but a drop-down to select the add on or VB Albums.

There is documentation to cover that, however...
Once the user clicks the drop-down menu, the NAVTAB "GALLERY" button is no longer "selected" and you do not have those nice sub-menu items.

This little combo hack will do this.

First, you must know the THIS_SCRIPT for the pages you will load with the drop-menu.

Once you know this, you can add them to the THIS_SCRIPT area and do two comparisons.
If you are not on one of the THIS_SCRIPT pages, the NAVTAB will be a drop-down.
If you are on one of the THIS_SCRIPT pages, the NAVTAB will be a selected link with submenu items.

Make a new plugin and add this code.

Code:
global $template_hook;
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'DROP Page 1' || THIS_SCRIPT == 'Drop PAGE 2')
{
    $vbulletin->options['selectednavtab']='droppage';
    $tabselected = ' class="selected"';
    $tablinks = '    
                       <ul class="floatcontainer">
                        <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>
                        <li><a href="Sublink4.php">Sublink 4</a></li>';
		</ul>';
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="MainPage.php">Drop Links</a>'.$tablinks.'</li>';
} 
else
{
$template_hook['navtab_middle'] .= '
<li class="popupmenu">
<a  href="javascript://" class="selected popupctrl navtab">Drop Links</a>
<ul class="popupbody popuphover">
<li><a rel="album" href="droplink1.php">Drop Link 1</a></li>
<li><a rel="gallery" href="droplink2.php">Drop Link 2</a></li>
</ul></li>';
}
Attached Thumbnails
Click image for larger version
Name:	drop.JPG
Views:	716
Size:	10.0 KB
ID:	110031   Click image for larger version
Name:	drop2.JPG
Views:	526
Size:	8.0 KB
ID:	110032  

vblts.ru supports vBulletin®, 2022-2024