vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Mini Mods - Navbar Tabs for CMS Sections (https://vborg.vbsupport.ru/showthread.php?t=259983)

hqarrse 03-06-2011 10:00 PM

Navbar Tabs for CMS Sections
 
1 Attachment(s)
*********** obsolete from VB 4.2 - see my post #24 for the much better way of doing it using Andreas' extension to the new Nav Manager *************

The lack of ability to put links to CMS sections as tabs in the Navbar seems a bizarre oversight, however... solved to some extent although pretty clunky:

This will work if you are adding navbar tabs for a top level section, ie. one that is not a sub section of your CMS home. That tab will then become 'selected' for that section, subsections and articles. It can probably we adapted for other situations.

Anything in CAPS below needs to be filled in with your own values.

Firstly you need to get the top level section ID (we have sub sections so just the section id is not enough) as a variable available to the Navbar and vbcms_navbar_link templates. The only way I have found to get this is to take the first item in the breadcrumb array. The plugin to do this is:

Hook: vbcms_content_populate_start
Code:

global $bci;
$bci = $this->content->getBreadcrumbInfo();
vB_Template::preRegister('navbar',array('top_parent' => $bci[0]['nodeid']));
vB_Template::preRegister('vbcms_navbar_link',array('top_parent' => $bci[0]['nodeid']));

Now we need a new tab for our section. Creating a tab is described in various places on vb.org, but in a nutshell the plugin is:

location: process_templates_complete
Code:

global $bci;
$tabselected = '';
$tablinks = '';
if ($bci[0]['nodeid'] == YOUR SECTION ID)
{
    $vbulletin->options['selectednavtab']='UNIQUENAME';
    $tabselected = ' class="selected"';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="LINK TO YOUR SECTION">YOUR SECTION</a></li>' ;

now you just need to disable the highlighting on the home tab for your section of the CMS. This is done by editing the template vbcms_navbar_link, and making the <li class="selected"> near the top as conditional. Change the existing <li class="selected"> to:
Code:

<vb:if condition="$top_parent != YOUR SECTION ID">
<li class="selected">
<vb:else />
<li>
</vb:if>

You can of course do multiple sections in this way by editing that condition to include all the top level section ids (!= a AND != b AND !=c...) where you don't want the 'Home' tab selected.

The screenshot shows the Reviews section of my site, with the various subsections appearing in the submenu area. This tab remains highlighted throughout the Reviews section, subsections and articles.

tekmiester 03-08-2011 11:28 PM

Any Demo or screenshot?

sticky 03-08-2011 11:50 PM

Yes please, screenshot as I think this may be what I have been looking for.

fluidswork 03-09-2011 03:04 AM

please post the screen-shot ..................

New Joe 03-09-2011 03:35 AM

Any chance of a screen shot?

hqarrse 03-09-2011 06:30 AM

It's not a very exciting screenshot - the VB 4 menu bar at the top of a CMS section! It just adds a navbar tab that can link to a CMS section. Normally it is only possible to add links to the submenu and they would all appear under "home"

I will be able to show show this on one of my sites in a couple of days and will post a link then. I did it for a new theme and it's not live yet.

sticky 03-09-2011 08:58 AM

I have been looking for something like this.

Can those links at the tops be used to link to anything? For example forum sections, member profiles, whatever?

hqarrse 03-09-2011 10:15 AM

You can do most things just by adding tabs as described by Lynne here: https://vborg.vbsupport.ru/showthread.php?t=226914

The mod above is specifically for CMS sections which are not as simple as just adding a tab. Sorry if I wan't clear.

strudinox 05-17-2011 06:13 AM

So far I've got this working perfectly with one tab, however, when I add multiple tabs, I can' get the syntax in the "vbcms_navbar_link" template to accept multiple tabs. I tried adding "AND" in between each one, but the result of it was Highlighting the Home link and the selected tab. What is the syntax you used on your site?

hqarrse 05-17-2011 04:35 PM

Hi, I did it like this:

Code:

<vb:if condition="$vboptions['selectednavtab'] == 'vbcms'">
<vb:if condition="$top_parent != 248 AND $top_parent != 357 AND $top_parent != 251 AND $top_parent != 255">
<li class="selected">
<vb:else />
<li>
</vb:if>



All times are GMT. The time now is 04:46 PM.

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.01047 seconds
  • Memory Usage 1,739KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete