Helpful Information
 
 
Category: vBulletin 4 Articles
NAVTAB Combo Drop-Menu with Sub-Items

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.



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>';
}

Nice Article. I get this error:

"Parse error: syntax error, unexpected '<' in /home/combatar/public_html/pfps/includes/class_bootstrap.php(509) : eval()'d code on line 52"

I will look what it is...

thanks alot 4 your work

Thanks Cory, very nice write-up! I now have 6 category drop-downs with 5 or so drop menus. :up:

Hi,

if i would like to create a plugin.
I need to choose "Add-on" and "Hook".

Can somebody tell me what to choose?

Thank you.

Skyborg

Don't work with 4.0.7.

I tried to implement that code but only get an error:
Parse error: syntax error, unexpected '<' in wholeserverpath/home/includes/class_bootstrap.php(517) : eval()'d code on line

Okay it seems to be that you have an error in your syntax


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>'; <--- this has to be erased ';
</ul>'; <--- Cause here its the end



And for some reason I don't why the submenu shows not right

I use the following hack and it works great.

http://www.vbulletin.org/forum/showthread.php?t=233629

This should be cleaner code no reason for an else in there.

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'script1' OR THIS_SCRIPT == 'script2')
{
$vbulletin->options['selectednavtab']='unique_name';
$tabselected = ' class="selected"';
$tablinks = '<ul class="floatcontainer">
<li><a href="link1.php">Link 1</a></li>
<li><a href="link2.php">Link 2</a></li>
</ul> ';
}
$template_hook['navtab_middle'] .= '
<li '.$tabselected.' class="popupmenu">
<a href="javascript://" class="popupctrl navtab">Members</a>
<ul class="popupbody popuphover">
<li><a style="text-indent: 0px; color:#000000" href="link1.php">Link 1</a></li>
<li><a style="color:#000000" href="link2.php">Link 2</a></li>
</ul>
'.$tablinks.'</li>
';

I'd like to use this mod but I am very confused as to the definition of this_script.

does this_script refer to page name such as forum.php, forumdisplay.php, showthread.php, etc?

is that what it means?

I'd like to use the tabbed menu built into vb4 because I'm currently using a commercial product in my vb3.8 install.

please help me understand.

I use the following hack and it works great.

http://www.vbulletin.org/forum/showthread.php?t=233629

thanks just installed this and it works great










privacy (GDPR)