PDA

View Full Version : Mini Mods - Navbar Tabs for CMS Sections


hqarrse
03-06-2011, 10:00 PM
*********** 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

global $bci;
$bci = $this->content->getBreadcrumbInfo();
vB_Template::preRegister('navbar',array('top_paren t' => $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

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:

<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:


<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>

Boofo
05-17-2011, 04:41 PM
You could easily make this in to a product for the plugins with the readme text file attached that explains the template edits.

strudinox
05-18-2011, 02:50 AM
Thanks for your help! Got it working perfectly! -Installed :D

hqarrse
05-18-2011, 10:10 AM
You could easily make this in to a product for the plugins with the readme text file attached that explains the template edits.

Too strapped for time at the moment to take this on, but I'll do that when I have a moment. You would hope that sooner or later this functionality would come as standard in VB as it seems such a basic, normal thing to want to do.

anolian
07-16-2011, 05:42 PM
Thanks so much hqarrse !! :)

I've been trying to figure out how to do this for ages, and that solves the problem completely! This woud make a fantastic and surely very popular mod - I'd vote it as MOTM definitely.

Yes, it is a bit clunky - but easy to do and solves a really important requirement simply and effectively. Very cool. :cool:

Thanks again.

mikeinjersey
08-07-2011, 04:50 PM
quick question so I don't screw this up.


YOUR SECTION ID

is just looking for a number and nothing else, right ? like 15 ?

Also, I have sub-Sections under my main Sections. (not categories) If I do one of the main Sections, will the sub-sections display automatically just underneath ?

for example : I have PS3 as a main section... and PS3 previews as the sub-section just underneath it.

thx much in advance

hqarrse
08-07-2011, 05:52 PM
Hi, yes you need the section ID number, and yes you will see your sub-sections. See my screenshot.

archet1337
08-12-2011, 08:03 PM
This is very nice. Any chance of getting the mod as a XML product?

hqarrse
08-15-2011, 07:36 AM
Not from me in the near future, sorry. I just don't have the time to take it on. Also you would hope that VB will enable you to do this at some point soon, so this will hopefully become an obsolete hack.

lild100
09-15-2011, 06:25 PM
Hey looks great!

To explain what I need Ill use your screen shot as an example.

If you see the nav tab 'games reviews'... If you was to put a article in there.... would the article also be displayed in the book reviews... if book reviews was called home tab.

So the home tab collects all the latest articles in each selected nav tab..

If this mod doesn't do you know how this can be done?

Thanks

Dan

Boofo
09-15-2011, 06:47 PM
Hey looks great!

To explain what I need Ill use your screen shot as an example.

If you see the nav tab 'games reviews'... If you was to put a article in there.... would the article also be displayed in the book reviews... if book reviews was called home tab.

So the home tab collects all the latest articles in each selected nav tab..

If this mod doesn't do you know how this can be done?

Thanks

Dan

Good luck! ;)

lild100
09-15-2011, 07:20 PM
Good luck! ;)

Did you get my email? :)

Ramjet79
10-03-2011, 10:55 PM
Hello. I am having a little trouble. I've got the plugins created, and can get a new tab to show up and to be clickable to it's proper destination.

However, I am having trouble with the highlighting, and the sub-sections showing up.

Right now, The HOME tab stays highlighted, and the default sections are displayed, rather than the sub-sections for the selected cms section.

I suspect it is a problem with my implementation of the code into the vbcms_navbar_link template.

I guess I am doing it wrong. Would someone mind pasting a working version of their "vbcms_navbar_link" template that I can reference to see why the tab is not being selected properly?

Thanks very much for anyone's help.

hqarrse
10-04-2011, 04:10 AM
Mine is this:


<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>
....
....

hqarrse
05-28-2012, 11:17 AM
This hack is obsolete from V 4.2 and using this mod to extend the navigation manager:

https://vborg.vbsupport.ru/showthread.php?t=283123

To make sub-sections highlight their parent section, just multiple select the sub-sections and the parent section in the 'Sections' listbox when adding a new tab in the admin panel.

The code mods in my hack can be safely removed. The template mod in vbcms_navbar_link should be removed.

Thanks to the VB team and Andreas for a flexible navigation system and the extension. It is a real pleasure to see the end of my hack!