vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Highlighting tabs when specific forums are displayed (https://vborg.vbsupport.ru/showthread.php?t=319055)

mattltm 06-13-2015 02:42 PM

Highlighting tabs when specific forums are displayed
 
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:
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 :)


All times are GMT. The time now is 01:15 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00965 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete