PDA

View Full Version : Highlighting tabs when specific forums are displayed


mattltm
06-13-2015, 02:42 PM
I have 2 menu buttons for the forums on my site, one which takes you to the Award forums and one which takes you the the Main forums.

I have used ?tabid=xx to highlight the correct "Award forums" menu button when the award forums are displayed but when someone clicks into a sub forum, the "Main forums" menu button is highlighted.

Is there a way that I can append ?tabid=xx to specific forums so that the correct menu button is highlighted when the forum is displayed? I know it will display as I want it because I can manually add ?tabid=xx to the forum link and get the correct result.

I guess I need some code that says "if this forum is a subforum of froumid 8 then append ?tabid=xx to the url"?

Thanks.

kh99
06-16-2015, 04:22 PM
Are you still looking for this? I think this works: create a plugin using hook set_navigaton_tab_main and this code:
global $forumid, $vbulletin;

$awards_forumid = X;
if (!empty($forumid) && $forumid != -1 && is_array($vbulletin->forumcache[$awards_forumid]))
{
if (in_array($forumid, explode(',',$vbulletin->forumcache[$awards_forumid]['childlist'])))
{
$root = 'tab_id';
}
}

You need to replace the X with the forumid of your awards forum, and the 'tab_id' with your tab id, which you can see as 'Identity' when you're editing the tab in the navigation manager (when I tested the code, my tab id was tab_ndq3_856, so it will be something like that).

mattltm
06-16-2015, 04:48 PM
Perfect. You are "The Man"!

I was scratching my head for ages with that!

kh99
06-16-2015, 04:52 PM
Oh, also you can set "Append 'tabid' to URL" to No since you don't need it with that plugin.

mattltm
06-16-2015, 04:55 PM
Next stupid question...

Can I do the same sort of thing for the calendar tab?

In the default view, the correct tab is highlighted because I've added "?tabid=61" to the end of the navigation link but if you click week or day view (for example) it highlights the "forum" tab.

I'm not smart enough to work out how to morph your code to work for it!

kh99
06-16-2015, 05:19 PM
I noticed a problem with the plugin. For the forum home page the forumid is -1 and it was selecting the Awards tab. I changed the code above to add a check for forumid != 1, so you probably want to copy the code again (sorry about that).

For the calendar, try setting Tab Script(s) to "calendar" (without the quotes) for that tab.

mattltm
06-17-2015, 03:12 PM
Sweet!

Thanks a bunch :)