Helpful Information
 
 
Category: vBulletin 4 Articles
[HOW TO - vB4] How add sub-menu drop down to the navbar (tab Forum)

This mod add sub-menu drop down to the navbar (tab Forum)

PS: Thank to Lynne for his help :)

First Method

Add new plugin- Product -> vbulletin
- hook location -> process_templates_complete
- Title -> menu x
- Execution Order -> 5
- Plugin PHP Code

$template_hook['navbar_end'] .= '
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Menu test</a>
<ul class="popupbody popuphover">
<li><a href="http://www.vbulletin-ressources.com/forum">test 1</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 2</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 3</a></li>
</ul> ';

Change location: ($template_hook['navbar_end'] in my example)

- navbar_end -> At the end to the navbar
- navbar_start -> At the beginning of the navbar
- navbar_after_getnew -> After "New Posts"
- navbar_after_pm -> After "Private Messages"
- navbar_after_faq -> After "Faq"
- navbar_after_calendar -> After "Calendar"
- navbar_after_community -> After "Community" button


Second method
In the "navbar" template, find:{vb:raw template_hook.navbar_end}
</ul>
</li>
<vb:elseif condition="$vboptions['selectednavtab']=='usercp'" />
Add above:<li class="popupmenu">
<a href="javascript://" class="popupctrl">Menu test</a>
<ul class="popupbody popuphover">
<li><a href="http://www.vbulletin-ressources.com/forum">test 1</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 2</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 3</a></li>
</ul>
</li>
Result:https://www.vbulletin.org/forum/external/2011/04/13.jpg

PS: Just change the links and titles.

In public now.

thanks for sharing Allan ;)

Can you help me with coding drop down tab menus for vB 3.8.4?

I am using additional CSS and placing the following code in the header,

<li id="current"><a href="#"><span>Tab 1</span></a></li>
<li><a href="#"><span>Tab 2</span></a></li>
<li><a href="#"><span>Tab 3</span></a></li>
<li><a href="#"><span>Tab 4</span></a></li>
<li><a href="#"><span>Tab 5</span></a></li>
<li><a href="#"><span>Tab 6</span></a></li>
<li><a href="#"><span>Tab 7</span></a></li>


but I have not been able to get the dropdown menus such as search and quick links to work.

Thanks!

Isn't this the same as http://www.vbulletin.org/forum/showthread.php?t=228338

Isn't this the same as http://www.vbulletin.org/forum/showthread.php?t=228338
No, this article is for navbar, no navtab.

If you can help us code this... we are willing to pay.

We tried this hack (http://www.vbulletin.org/forum/showthread.php?t=200684&highlight=tabs), and everything works fine, other than getting dropdown menus to work with the tab list.

Is there a way to have this work on the CMS as well?

thank you for this very good

thanks alot ... this is very useful

I installed this hack. It is great.

I am using a customised menu to search new posts in specific categories. - using this hack.

One problem I am facing is, after the execution of the search?.., the tab switches to "What's New ?" tab. Original search menu is under Forums, how to use this menu option but not switch the tab to What's New ?

Thanks in advance.

my forum : http://www.r2iclubforums.com/forums/

Hi, what if I just want a link there. I mean just like, new post, private messages faq or calender?

Thanks in advance. :)

Its possible a sub-sub-sub menu ? thanks

Also want to just make a single link in CMS area (home page).

Okay... how would I ITERATE this?

For instance... this is my navtab template:
<vb:if condition="$vboptions['selectednavtab'] == 'media'">
<li class="selected">
<a class="navtab" href="media.php{vb:raw session.sessionurl_q}">Media</a>
<ul class="floatcontainer">
<li><a href="media.php{vb:raw session.sessionurl_q}">Media Home</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Categories</a>
<ul class="popupbody popuphover">
{vb:raw catbits}
</ul>
</li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="media.php{vb:raw session.sessionurl_q}">Media</a></li>
</vb:if>

You'll notice, instead of the actual subbits, I have a raw variable called "catbits". The code for getting the catbits would be as follows:
$categories = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "media_category");
while ($category = $vbulletin->db->fetch_array($categories))
{
$templater = vB_Template::create('media_NAVTAB_bit');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$catbits .= $templater->render();
}

Where would I put this code? And how do I register the $catbits variable into the hook?

--------------- Added 1269835210 at 1269835210 ---------------

Okay... trying things out, I was able to get it working by using this plugin....

if (THIS_SCRIPT == 'media')
{
$vbulletin->options['selectednavtab'] = 'media';
}

$categories = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "media_category");
while ($category = $vbulletin->db->fetch_array($categories))
{
$templater = vB_Template::create('media_NAVTAB_bit');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$catbits .= $templater->render();
}

$templater = vB_Template::create('media_NAVTAB');
$templater->register('catbits', $catbits);
$template_hook['navtab_middle'] .= $templater->render();

However, obviously this adds an extra query on EVERY page. Is there a better way to do this?

thanks, trying it out now on our test server.

Hi, great tip to get a dropdown menu.
I implemented it and it appears in the Forum tab.

But now, I'd like to implement it in the CMS frontpage section.
Can you tell me how to do this?

Thanks!

thank you

Thank you SO much! I used option 1. Very easy mod to do, and easy to add as many links as I need.

This is a great hack. Thank you. Btw is there a way to make it so members can only see it.

Could anybody point me in the right direction of getting this effect?

https://www.vbulletin.org/forum/external/2011/04/17.jpg

I addet this but the Problem is that it is shown if i click on the "Forum" Button. I addet a "Portal"-Button. How can i make that it appears there and not by the Forum Button?

https://www.vbulletin.org/forum/external/2011/04/10.png

This artilce is about adding the sub-menus, not the navtabs. You need to have the correct condition around your navtab to show it at the correct place. You should ask your question in the modification thread that you use for the navtab.

But this has nothing to do with the modification, because i am sure many persons want to add sub-menus as example under the standard buttons like "whats new" and the "blog" and not only by the "forum" button so the question is how to specify that

And if you wrote the navtab correctly, then you would have the submenus showing. I have an article in my profile on how to correctly write a plugin to create a navtab with submenus.

Thank you very much Lynne your article was the perfect description to solve my problem. Only thing i still need is to know how to translate (add Phrases) to this new buttons. Because i am using a multilingual Forum

Thank you very much Lynne your article was the perfect description to solve my problem. Only thing i still need is to know how to translate (add Phrases) to this new buttons. Because i am using a multilingual Forum
Instead of putting text for the links:
<a href="link.php">My Link</a>

Use phrases (you will need to enter them into the phrase manager as global phrases):
<a href="link.php">$vbphrase[my_link]</a>

Thank you i addet all the submenus i needet. Only two are making me problems

1. The "Who's Online" Menu. I get this Error Message showing if i write it like that

Parse error: syntax error, unexpected T_STRING in /www/htdocs/w00d3776/vbulletin/includes/class_bootstrap.php(537) : eval()'d code on line 84

If i write it like Whos Online without ' it makes no problems but why cant i write it like in the Original way?

2. The "Open Contacts Popup"

If i add the code like this

<li><a onclick="window.open(getBaseUrl() + 'misc.php?do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no, scrollbars=yes,resizable=yes,width=250,height=300'); return false;" href="javascript://">Open Contacts Popup</a></li>

i get this error message

Parse error: syntax error, unexpected T_STRING in /www/htdocs/w00d3776/vbulletin/includes/class_bootstrap.php(537) : eval()'d code on line 82

hope that a solution for this problems exists thanks for any help

If you are writing this in php output, you need to escape the character if that is what you have surrounding the output - \'

I am not sure how to do that i think i can solve the first problem with writing Whos Online and add the correct writing to phrases but i am not sure how to change the Open contacts popup to make it work

--------------- Added 1304101672 at 1304101672 ---------------

Adding the phrases is making me problems i did it step by step but it looks like this now

https://www.vbulletin.org/forum/external/2011/04/3.png

https://www.vbulletin.org/forum/external/2011/04/4.png

https://www.vbulletin.org/forum/external/2011/04/5.png

Thank you!

Hi, great tip to get a dropdown menu.
I implemented it and it appears in the Forum tab.

But now, I'd like to implement it in the CMS frontpage section.
Can you tell me how to do this?

Thanks!

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

I used that thread to do that.

Hi, I want to ask, how to make submenu in my Home tab?

Hi, I want to ask, how to make submenu in my Home tab?
Same way. Only find the template_hook names in the vbcms_navbar_link template.

Same way. Only find the template_hook names in the vbcms_navbar_link template.

Thank you, that's works.:up:

Excuse me for the stupid question, but how to add another drop-down menu next to the first one?

Thank you so much for this!! How do you make it visible only to a secondary usergroup?

So this is not in 4.1.9? "process_templates_complete"

So this is not in 4.1.9? "process_templates_complete"
That hook location still exists.

Is it possible with this hack (using the 2nd method Allan described) to create a second set of submenus that follow from the first? A bit like what was described in Post #21 (http://www.vbulletin.org/forum/showpost.php?p=2182394&postcount=21)?

I have a large number of links and it would be useful to use a categorised set of sub-menus.

Thanks for posting up how to do this.

Same way. Only find the template_hook names in the vbcms_navbar_link template.


How about just adding a single Navbar link to my Home/Forum/Blog Navbar (no submenus)?

What would be the correct coding for that?

Thanks!

How about just adding a single Navbar link to my Home/Forum/Blog Navbar (no submenus)?

What would be the correct coding for that?

Thanks!

$template_hook['vbcms_navbar_end'] .= '<li><a href="Your Link">Link Title</a></li>';

That is what I used in order to get the link on my homepage.

I would also like to ask for insight as to how to set the link so that only users with permissions can see the link.

Put a condition around it.

if (is_member_of($vbulletin->userinfo, x, y, z) {
code
}

Put a condition around it.

if (is_member_of($vbulletin->userinfo, x, y, z) {
code
}

Lynne, Thanks for the response. I used the following code in total and I didn't get a parsing error.

if (is_member_of($vbulletin->userinfo, Administrators)) {
$template_hook['vbcms_navbar_end'] .= '<li><a href="mylink">My Link</a></li>';
}

However, as the Admin I cannot see the link. Also, how would I add in usergroup names for permissions if the usergroup names have spaces in them?

Thanks again for your help :)

x,y, and z are the usergroupids, not usergroup names. Replace Administrator with the usergroupid of your Administrator usergroup.

Excellent! Thanks again Lynne, it worked perfectly.

update 4.2.0 and not found please ...

I'm wondering if anyone can advise on this?

VBulletin has special PHP variables that you can use in notices, such as {userid} and {username}, which will generate an output specific to the user.

I would like to use these variables in a search string (I know this works in notices) but, obviously, it doesn't work in these dropdowns because the search string is in javascript and won't be parsed (see example code below).

Is it somehow possible to get the special variable parsed server-side, then handed over to the javascript?

I've seen people talk about it, but nobody's provided a solution.

Thanks,
tambo


<li class="popupmenu">
<a href="javascript://" class="popupctrl">Menu test</a>
<ul class="popupbody popuphover">
<li><a href="http://www.example.com/search.php?do=process&query={username}">Test Search</a></li>
</ul>
</li>

The variable you would use would depend on the template you use it in. Most likely you would be wanting $bbuserinfo[username]

haha... I'm afraid you might need to guide me a little more than that.

Is it possible to modify the code above so that I can understand where that variable would go and how it would be passed over to the javascript / hyperlink?

Try something more like:

http://www.example.com/search.php?do=process&query={vb:raw bbuserinfo.username}

Ah, Lynne.... you absolute star!

Thankyou.

<3

Where can I find the CSS for the drop down menu?

I'd like to customise the CSS to my own liking for my forum and add it to additional.css!

Thanks.

I can`f find second method (navbar template on VB 4.2.0 PL3
<div id="navbar" class="navbar">
<ul id="navtabs" class="navtabs floatcontainer<vb:if condition="$show['member'] AND $notifications_total"> notify</vb:if>">
{vb:raw template_hook.navtab_start}
{vb:raw navigation}
{vb:raw template_hook.navtab_end}
</ul>
<vb:if condition="$vboptions['enablesearches']">
<div id="globalsearch" class="globalsearch">
<form action="search.php?{vb:raw session.sessionurl}do=process" method="post" id="navbar_search" class="navbar_search">
<vb:comment><input type="hidden" name="s" value="{vb:raw session.sessionurl}" /></vb:comment>
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<input type="hidden" name="do" value="process" />
<span class="textboxcontainer"><span><input type="text" value="" name="query" class="textbox" tabindex="99"/></span></span>
<span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search<vb:if condition="$stylevar['textdirection'] == 'rtl'">_rtl</vb:if>.<vb:if condition="is_browser('ie') AND !is_browser('ie', 7)">gif<vb:else />png</vb:if>" name="submit" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span>
</form>
<ul class="navbar_advanced_search">
<li><a href="search.php{vb:raw session.sessionurl_q}" accesskey="4">{vb:rawphrase advanced_search}</a></li>
{vb:raw template_hook.navbar_advanced_search}
</ul>
</div>
</vb:if>
</div>
</div><!-- closing div for above_body -->

<div class="body_wrapper">
<div id="breadcrumb" class="breadcrumb">
<ul class="floatcontainer">
<li class="navbithome"><a href="index.php{vb:raw session.sessionurl_q}" accesskey="1"><img src="{vb:stylevar imgdir_misc}/navbit-home.png" alt="{vb:rawphrase home}" /></a></li>
{vb:raw navbits.breadcrumb}
{vb:raw navbits.lastelement}
</ul>
<hr />
</div>

{vb:raw ad_location.ad_navbar_below}
{vb:raw ad_location.global_below_navbar}

<vb:if condition="$show['notices'] AND THIS_SCRIPT != 'register'">
<form action="profile.php?do=dismissnotice" method="post" id="notices" class="notices">
<input type="hidden" name="do" value="dismissnotice" />
<input type="hidden" name="s" value="{vb:raw session.sessionurl}" />
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<input type="hidden" id="dismiss_notice_hidden" name="dismiss_noticeid" value="" />
<input type="hidden" name="url" value="{vb:raw return_link}" />
<ol>
{vb:raw notices}
</ol>
</form>
</vb:if>

--------------- Added 1367648798 at 1367648798 ---------------

Any Idea how to add this code
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Menu test</a>
<ul class="popupbody popuphover">
<li><a href="http://www.vbulletin-ressources.com/forum">test 1</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 2</a></li>
<li><a href="http://www.vbulletin-ressources.com/forum">test 3</a></li>
</ul>
</li>

Seems people don't want to mess with updating this anymore.

Mega Menu? Nested dropdowns? Put a menu with links inside a menu?

Seems people don't want to mess with updating this anymore.

Mega Menu? Nested dropdowns? Put a menu with links inside a menu?
This article covers one thing - adding a sub-menu downdown to the navbar. There is nothing in the description that says anything about covers those other items.










privacy (GDPR)