PDA

View Full Version : [HOW TO - vB4] How add sub-menu drop down to the navbar (tab Forum)


Allan
08 Jan 2010, 23:08
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.

Allan
09 Jan 2010, 20:12
In public now.

KURTZ
09 Jan 2010, 20:19
thanks for sharing Allan ;)

ShackMaster
13 Jan 2010, 20:33
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!

ragtek
13 Jan 2010, 20:50
Isn't this the same as http://www.vbulletin.org/forum/showthread.php?t=228338

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

ShackMaster
13 Jan 2010, 21:13
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.

skor
18 Jan 2010, 03:52
Is there a way to have this work on the CMS as well?

ahmedipa
24 Jan 2010, 09:01
thank you for this very good

as7apcool
24 Jan 2010, 09:34
thanks alot ... this is very useful

Desibabu19
15 Feb 2010, 14:16
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/

Forum Lover
03 Mar 2010, 14:47
Hi, what if I just want a link there. I mean just like, new post, private messages faq or calender?

Thanks in advance. :)

xony
04 Mar 2010, 16:32
Its possible a sub-sub-sub menu ? thanks

Paul B
06 Mar 2010, 22:38
Also want to just make a single link in CMS area (home page).

Jaxel
29 Mar 2010, 04:55
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?

slimgamer
05 May 2010, 03:10
thanks, trying it out now on our test server.

duckchief
13 May 2010, 10:30
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!

g10net
15 May 2010, 16:43
thank you

tcarr9
19 Jan 2011, 14:52
Thank you SO much! I used option 1. Very easy mod to do, and easy to add as many links as I need.

Lostboyfan
05 Apr 2011, 03:10
This is a great hack. Thank you. Btw is there a way to make it so members can only see it.

Da-Vinci
08 Apr 2011, 21:04
Could anybody point me in the right direction of getting this effect?

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

Mustiii
27 Apr 2011, 16:33
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

Lynne
27 Apr 2011, 18:14
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.

Mustiii
27 Apr 2011, 20:58
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

Lynne
28 Apr 2011, 05:29
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.

Mustiii
28 Apr 2011, 16:39
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

Lynne
28 Apr 2011, 17:58
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>

Mustiii
28 Apr 2011, 18:43
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

Lynne
28 Apr 2011, 22:11
If you are writing this in php output, you need to escape the character if that is what you have surrounding the output - \'

Mustiii
28 Apr 2011, 22:30
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

8thos
23 Jun 2011, 23:55
Thank you!

LordEd
27 Jun 2011, 21:12
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.

bg-network
07 Aug 2011, 18:13
Hi, I want to ask, how to make submenu in my Home tab?

Lynne
07 Aug 2011, 18:29
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.

bg-network
07 Aug 2011, 20:18
Same way. Only find the template_hook names in the vbcms_navbar_link template.

Thank you, that's works.:up:

bg-network
08 Aug 2011, 20:44
Excuse me for the stupid question, but how to add another drop-down menu next to the first one?

CouponWCents
18 Oct 2011, 13:36
Thank you so much for this!! How do you make it visible only to a secondary usergroup?

grasshoper
17 Jan 2012, 18:18
So this is not in 4.1.9? "process_templates_complete"

Lynne
17 Jan 2012, 23:57
So this is not in 4.1.9? "process_templates_complete"
That hook location still exists.

tambo
14 Feb 2012, 18:02
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.

06GTOAZ
15 Feb 2012, 05:37
Thanks for posting up how to do this.

MacroPhotoPro
03 Apr 2012, 02:35
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!

rodeojones
25 Apr 2012, 21:29
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.

Lynne
25 Apr 2012, 22:34
Put a condition around it.

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

rodeojones
30 Apr 2012, 22:02
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 :)

Lynne
30 Apr 2012, 23:33
x,y, and z are the usergroupids, not usergroup names. Replace Administrator with the usergroupid of your Administrator usergroup.

rodeojones
01 May 2012, 15:21
Excellent! Thanks again Lynne, it worked perfectly.

xony
02 Jun 2012, 18:48
update 4.2.0 and not found please ...

tambo
31 Oct 2012, 12:27
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>

Lynne
31 Oct 2012, 16:38
The variable you would use would depend on the template you use it in. Most likely you would be wanting $bbuserinfo[username]

tambo
03 Nov 2012, 12:07
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?

Lynne
03 Nov 2012, 17:41
Try something more like:

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

tambo
05 Nov 2012, 19:46
Ah, Lynne.... you absolute star!

Thankyou.

<3

Blue-Inc
01 May 2013, 20:35
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.

Jpolola
04 May 2013, 07:22
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>

StonePilot
30 Apr 2014, 21:43
Seems people don't want to mess with updating this anymore.

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

Lynne
30 Apr 2014, 22:08
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.