vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Create a New Tab in the navbar (https://vborg.vbsupport.ru/showthread.php?t=226914)

JErix 11-22-2011 07:17 PM

Thanks for the tut. I'm a complete newb and it took a little reading, but, I got it figured out. :)

kfyonur 11-30-2011 10:17 AM

thank you lynee very nice.

kfyonur 12-04-2011 10:39 AM

is it correct ?

Code:

$tabselected = '';
$tablinks = '';
if ($GLOBALS['forumid'] == 66)
{
    $vbulletin->options['selectednavtab']='audiservis';
    $tabselected = ' class="selected"';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.audiclubtr.com/f66/">Audi Servis</a>'.$tablinks.'</li>' ;


Lynne 12-05-2011 04:06 AM

It looks correct. Did you try it?

GE-Tom 12-05-2011 09:37 AM

It is correct. Works fine with my urls.

@ Lynne

mutch thanks for this great tutorial. helps me a lot. now i only must finde out how i add a dropdown for my main menu tab.

gm139 12-11-2011 07:56 PM

I am using vbulletin suite 418. I would like to add 3 tabs on the navbar, so I have copied your code 3 times in the plugin.
Each tab points to to the page content.php, followed by different parameters for each page. Links work, so when I click on a tab the correct page is shown, but the tab is not highligheted. Any suggestion?

Lynne 12-11-2011 08:22 PM

Quote:

Originally Posted by gm139 (Post 2276844)
I am using vbulletin suite 418. I would like to add 3 tabs on the navbar, so I have copied your code 3 times in the plugin.
Each tab points to to the page content.php, followed by different parameters for each page. Links work, so when I click on a tab the correct page is shown, but the tab is not highligheted. Any suggestion?

You need to create a unique condition for each page. Replace this:
PHP Code:

if (THIS_SCRIPT == 'yourpage'

With a unique condition for the page. It does not have to be a condition based on the variable THIS_SCRIPT. It may be any unique condition.

gm139 12-11-2011 08:51 PM

Quote:

Originally Posted by Lynne (Post 2276851)
You need to create a unique condition for each page. Replace this:
PHP Code:

if (THIS_SCRIPT == 'yourpage'

With a unique condition for the page. It does not have to be a condition based on the variable THIS_SCRIPT. It may be any unique condition.

As suggested at post 423 I have modified the script in this way but it does not work yet.

Code:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'vbcms' && $_SERVER['REQUEST_URI'] == '/content.php?3-prossima-trasferta')
{
    $vbulletin->options['selectednavtab']='prossima-trasferta';
    $tabselected = ' class="selected"';
    $tablinks = '                <ul class="floatcontainer">
                        <li><a href="link1.php">Link 1</a></li>
                            <li class="popupmenu">
                                <a href="javascript://" class="popupctrl">Drop Down</a>
                                <ul class="popupbody popuphover">
                                        <li><a href="sublink1.php">SubLink 1</a></li>
                                        <li><a href="sublink2.php">SubLink 2</a></li>
                                        <li><a href="sublink3.php">SubLink 3</a></li>
                                </ul>
                            </li>
                        <li><a href="link2.php">Link 2</a></li>
                        <li><a href="link3.php">Link 3</a></li>
                </ul> ';


$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?3-prossima-trasferta">Prossima trasferta</a>'.$tablinks.'</li>' ;


Hippy 12-11-2011 09:33 PM

Code:

if (THIS_SCRIPT == 'vbcms' && $_SERVER['REQUEST_URI'] == '/content.php?3-prossima-trasferta')
the line above should only read
Code:

if (THIS_SCRIPT == 'vbcms')
I think..

gm139 12-11-2011 10:22 PM

Quote:

Originally Posted by Hippy (Post 2276883)
Code:

if (THIS_SCRIPT == 'vbcms' && $_SERVER['REQUEST_URI'] == '/content.php?3-prossima-trasferta')
the line above should only read
Code:

if (THIS_SCRIPT == 'vbcms')
I think..

no, because I call the content.php from different tabs.

Lynne 12-11-2011 10:39 PM

Have you tried spitting out $_SERVER['REQUEST_URI'] on the page to verify you have it set correctly for the page? It may be different than in that example based on the type of Friendly URLs you are using.

And did you make the change to the plugin also?

gm139 12-11-2011 11:00 PM

Quote:

Originally Posted by Lynne (Post 2276892)
Have you tried spitting out $_SERVER['REQUEST_URI'] on the page to verify you have it set correctly for the page? It may be different than in that example based on the type of Friendly URLs you are using.

And did you make the change to the plugin also?

No. I do. I'm using a eloquent red skin. I want to try with the deafault one too. No I didn't modifi the plugin.

--------------- Added [DATE]1323682221[/DATE] at [TIME]1323682221[/TIME] ---------------

Quote:

Originally Posted by gm139 (Post 2276902)
No. I do. I'm using a eloquent red skin. I want to try with the deafault one too. No I didn't modifi the plugin.

tried. REQUEST_URI is empty. Any idea?

--------------- Added [DATE]1323688580[/DATE] at [TIME]1323688580[/TIME] ---------------

I have finally found a way that works, with this condition:

Code:

if ($_SERVER['HTTP_REFERER'] == 'http://www.piacenzacalcio.net/vb/content.php?3-prossima-trasferta')
The condition is verified, but still the tab is not highlighted and submenus do not appear. here is the plugin:

Code:

$tabselected = '';
$tablinks = '';

if ($_SERVER['HTTP_REFERER'] == 'http://www.piacenzacalcio.net/vb/content.php?3-prossima-trasferta')
{  $vbulletin->options['selectednavtab']='prossimatrasferta';
    $tabselected = ' class="selected"';
    $tablinks = '                <ul class="floatcontainer">
                        <li><a href="link1.php">Link 1</a></li>
                            <li class="popupmenu">
                                <a href="javascript://" class="popupctrl">Drop Down</a>
                                <ul class="popupbody popuphover">
                                        <li><a href="sublink1.php">SubLink 1</a></li>
                                        <li><a href="sublink2.php">SubLink 2</a></li>
                                        <li><a href="sublink3.php">SubLink 3</a></li>
                                </ul>
                            </li>
                        <li><a href="link2.php">Link 2</a></li>
                        <li><a href="link3.php">Link 3</a></li>
                </ul> ';

*/echo $tablinks;
die();*/


$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?3-prossima-trasferta">Prossima trasferta</a>'.$tablinks.'</li>' ;

I have verified that $tablinks is not empty, through the echo you can see.

intruder 12-18-2011 03:01 PM

UP, it would be great to have something like

Code:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'test' OR in_array($GLOBALS['forumid'], array(58, 59, 60, 56)))

for the cms also.

THIS_SCRIPT == 'test' -> vbcmspage
forum.id -> section.id

Any ideeas?

malinghi 01-21-2012 11:15 PM

Forgive me if someone asked this, but I didn't see anything like this in the comments. I want a tab on the navbar to randomly link to one of a couple dozen websites. I found code to do this with javascript or with php, and the code works fine, but I can't figure out how to incorporate it into the code for the tab.

Here's one of the codes I found for making a random link:

PHP Code:

$links = array("link 1""link 2""link 3");
$max sizeof($links);
$rand rand(0$max);
echo (
"<a href = \"$links[$rand]\">Click Here for a Random Link</a>"); 

I've tried to just insert something after href=, like $links[$rand], or echo($links[$rand]), or print($links[$rand]), into the last line of the code for the plugin but then the navbar link just takes me to www.mywebsite.com/$links[$rand].
PHP Code:

<class="navtab" href=$links[$rand]>Nav Link</a>'.$tablinks.'</li>' ; 

I've considered using the random number generator to send it to a bunch of if statements with each one having the last line from your code but with a different url, but I was worried that having dozens of if statements get evaluated every time someone loads a page on my site might slow it down or be bad for it or something.

Lynne 01-22-2012 12:08 AM

It would need to be something like this:
PHP Code:

<class="navtab" href="'.$links[$rand].'" >Nav Link</a>'.$tablinks.'</li> ; 


malinghi 01-22-2012 09:36 AM

I'm not sure why, but it didn't work. This is the full version of the last line, just to make sure I inserted the code correctly:

PHP Code:

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href=$links[$rand]>Nav Link</a>'.$tablinks.'</li> ; 

And the error I get is:


Code:

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62

Parse error: syntax error, unexpected '<' in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62


TheSupportForum 01-22-2012 11:54 AM

Quote:

Originally Posted by malinghi (Post 2290906)
I'm not sure why, but it didn't work. This is the full version of the last line, just to make sure I inserted the code correctly:

PHP Code:

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href=$links[$rand]>Nav Link</a>'.$tablinks.'</li> ; 

And the error I get is:


Code:

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62

Parse error: syntax error, unexpected '<' in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62


asuming you are using a plugin for this try this

Code:


        $template_hook['navtab_end'] .= ('<li'.$tabselected.'><a class="navtab" href=$links[$rand]>Nav Link</a>'.$tablinks.</li>');


malinghi 01-22-2012 02:28 PM

Simonhind, I just tried the code you suggested. It didn't give the "Warning: Unexpected character in input" error, but it did still give the parse error about the '<' bracket. Here's the full error message.

Code:

Parse error: syntax error, unexpected '<' in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62

leftanalog 01-24-2012 02:25 AM

Im not sure why, but I cannot get ANY tabs to show up to the right of the what's new tab. Ive tried Mods (from vb.org) as well as this. Ive tried this code stock. I cannot get ANY tab to show up to the right of my "What's New" tab.

Currently I only have FORUMS, and WHATS NEW.

What could be the issue? Any help please?

TheSupportForum 01-24-2012 09:17 AM

does anyone know the css to increase the height of the tabs

------
edit : found the styvar, now thats looking better

--------------- Added [DATE]1327405000[/DATE] at [TIME]1327405000[/TIME] ---------------

Quote:

Originally Posted by malinghi (Post 2290967)
Simonhind, I just tried the code you suggested. It didn't give the "Warning: Unexpected character in input" error, but it did still give the parse error about the '<' bracket. Here's the full error message.

Code:

Parse error: syntax error, unexpected '<' in /home/mernet/public_html/index/includes/class_bootstrap.php(555) : eval()'d code on line 62

can you provide the full plugin code, either here or via PM and i'll take a proper look

Ziki 01-24-2012 12:10 PM

Hi Lynne,

is it possible to make the dropdown menu a link? I mean that clicking the arrow next to the item would result in showing the dropdown, but clicking the actual link would take you to the page I specify?

Thanks

Lynne 01-24-2012 04:25 PM

Quote:

Originally Posted by leftanalog (Post 2291593)
Im not sure why, but I cannot get ANY tabs to show up to the right of the what's new tab. Ive tried Mods (from vb.org) as well as this. Ive tried this code stock. I cannot get ANY tab to show up to the right of my "What's New" tab.

Currently I only have FORUMS, and WHATS NEW.

What could be the issue? Any help please?

What template_hook are you using? What execution order?

Quote:

Originally Posted by Ziki (Post 2291711)
Hi Lynne,

is it possible to make the dropdown menu a link? I mean that clicking the arrow next to the item would result in showing the dropdown, but clicking the actual link would take you to the page I specify?

Thanks

I would guess you could, but you'd need to change the <a> tags and probably include the image for the dropdown and link to it also.

leftanalog 01-24-2012 04:47 PM

Quote:

Originally Posted by Lynne (Post 2291811)
What template_hook are you using? What execution order?

I think I figured it out.

Had a custom hook
{vb:raw template_hook.navbar_after_getnew}

edit: Nvm taking that out didnt do anything.

So this is the coding for my navbar tabs

PHP Code:

{vb:raw template_hook.navtab_start}
        <
vb:if condition="!$vboptions['selectednavtab'] AND THIS_SCRIPT != 'search'">
            <
li class="selected"><class="navtab" href="http://leftanalog.net/forums">{vb:rawphrase forum}</a>
                <
ul class="floatcontainer">
                    {
vb:raw template_hook.navbar_start}
                    <
vb:if condition="$show['searchbuttons']">
                        <
vb:if condition="$show['member']">
                        <
vb:else />
                        <
li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase todays_posts}</a></li>
</
vb:if>
</
vb:if> 

Then it goes into the lower bar under the tabs and starts with those. Is there anything in there, that would prevent a tab to display to the right of What's New".

I cant figure it out. It must be a conflicting plugin?

Im not that great with VB language. Any help would be appreciated.

EDIT 2: I figured it out. Well not really, but I just reverted my template and started it from scratch again. Not sure what I was missing or what, but I have the results I wanted by reverting it, and then modifying that code.

Thanks

JErix 01-24-2012 08:46 PM

Hello, great description. Took me a minute to figure it out, but, I got it working and I'm a pretty big newb, so, thank you. :)

I was wondering if there was a way to insert the new tab in a specific spot along the menu. I have 5 tabs so far, and I want this new one I created to be 4th in line. I know you can do navtab_middle, navtab_end, but, neither of those will put it in the 4th position.

Thanks for any info on how to change this.

Cheers.

Lynne 01-24-2012 09:29 PM

Quote:

Originally Posted by JErix (Post 2291925)
Hello, great description. Took me a minute to figure it out, but, I got it working and I'm a pretty big newb, so, thank you. :)

I was wondering if there was a way to insert the new tab in a specific spot along the menu. I have 5 tabs so far, and I want this new one I created to be 4th in line. I know you can do navtab_middle, navtab_end, but, neither of those will put it in the 4th position.

Thanks for any info on how to change this.

Cheers.

You may need to also change the execution order to get it into the exact right spot.

JErix 01-24-2012 11:25 PM

Quote:

Originally Posted by Lynne (Post 2291934)
You may need to also change the execution order to get it into the exact right spot.

I changed it to 4, and saved, since I want in the #4 spot. But, it's still in the middle (I'm using nav_middle at the present time). Would I also have to change the execution order of the other tabs? :o (I don't know where to look for those since I did not create plugins for them)

malinghi 01-26-2012 02:24 AM

Quote:

can you provide the full plugin code, either here or via PM and i'll take a proper look
PHP Code:

$tabselected ''
$tablinks ''
if (
THIS_SCRIPT == 'guides_script'

    
$vbulletin->options['selectednavtab']='Guides'
    
$tabselected ' class="selected"'
}  


$links = array("link 1""link 2""link 3");
$max sizeof($links);
$rand rand(0$max);

$template_hook['navtab_end'] .= ('<li'.$tabselected.'><a class="navtab" href=$links[$rand]>Nav Link</a>'.$tablinks.</li>'); 


This should be basically the same as the original plugin code Lynne posted. I took out the code for the drop down menu.

Travis-Mc 01-26-2012 06:59 AM

Quote:

Originally Posted by gm139 (Post 2276902)
No. I do. I'm using a eloquent red skin. I want to try with the deafault one too. No I didn't modifi the plugin.

--------------- Added [DATE]1323682221[/DATE] at [TIME]1323682221[/TIME] ---------------



tried. REQUEST_URI is empty. Any idea?

--------------- Added [DATE]1323688580[/DATE] at [TIME]1323688580[/TIME] ---------------

I have finally found a way that works, with this condition:

Code:

if ($_SERVER['HTTP_REFERER'] == 'http://www.piacenzacalcio.net/vb/content.php?3-prossima-trasferta')
The condition is verified, but still the tab is not highlighted and submenus do not appear. here is the plugin:

Code:

$tabselected = '';
$tablinks = '';

if ($_SERVER['HTTP_REFERER'] == 'http://www.piacenzacalcio.net/vb/content.php?3-prossima-trasferta')
{  $vbulletin->options['selectednavtab']='prossimatrasferta';
    $tabselected = ' class="selected"';
    $tablinks = '                <ul class="floatcontainer">
                        <li><a href="link1.php">Link 1</a></li>
                            <li class="popupmenu">
                                <a href="javascript://" class="popupctrl">Drop Down</a>
                                <ul class="popupbody popuphover">
                                        <li><a href="sublink1.php">SubLink 1</a></li>
                                        <li><a href="sublink2.php">SubLink 2</a></li>
                                        <li><a href="sublink3.php">SubLink 3</a></li>
                                </ul>
                            </li>
                        <li><a href="link2.php">Link 2</a></li>
                        <li><a href="link3.php">Link 3</a></li>
                </ul> ';

*/echo $tablinks;
die();*/


$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?3-prossima-trasferta">Prossima trasferta</a>'.$tablinks.'</li>' ;

I have verified that $tablinks is not empty, through the echo you can see.

If I understand your problem, you're trying to get your new tabs to be "selected" after you click on them, and they are page in the CMS like content.php?XX

This is what I did:

For each CMS Page create a plugin and the condition in the plugin would be something like this:

PHP Code:

if ($vbulletin->nodeid == XX

Where XX is the nodeid of the page

Since the articles are in the CMS, both the home tab and your new tab will be selected. To fix this, edit the plugin called
"Navbar: Insert CMS Navbar Entry"

Find:
PHP Code:

if (defined('CMS_SCRIPT') AND class_exists('vBCms_Navbar')) 

Replace:
PHP Code:

if (defined('CMS_SCRIPT') AND class_exists('vBCms_Navbar') AND !in_array($vbulletin->nodeid, array(XXXXXX))) 

I hope that helps.

fldewey 02-13-2012 06:33 PM

This is a great article - thanks to all who contributed.

What I am trying to do is add one more level to the dropdown. So for example if I click a pulldown, when I mouseover one of the options another set of options will display.

I thought I could add another <ul class="popupbody popuphover"> to this code, but that just covers the current menu up.

Can someone point me in the right direction? I'm not sure if this might be outside of the scope here.

Thanks

Akyeame Kwame 03-20-2012 09:49 PM

Hello,

I tried searches for separate, several, more than, and different so if it's been mentioned, I couldn't find it through all the pages.

I'd like to make several different tabs but when I do this with different plugins, the first one is in the bold style of the menu but the second one is just plain text in the style of the sub-menu. Should I put all the new tabs into one plugin? If so how? If I keep them in separate plugins, how do I keep them all in the same style of the top menu?

EDIT: I found the issue. The second time around I missed copying $tabselected = ''; so it was missing from the top. Works fine now.

MacroPhotoPro 04-02-2012 09:44 PM

Thank you for making this Mod, I got it working fine now :)

Christos Teriakis 05-23-2012 04:04 PM

Is this compatible with vB42? Because everything that I was using related to NavBar simple does not works. No errors, but ...nothing to see there.

Thank you
Chris

Lynne 05-23-2012 10:05 PM

The only $template_hooks in vB4.2 navbar template are navbar_start and navbar_end, so only those two will work to add a navtab. However, the code to make a tab selected has totally changed, so that code will cause issues in 4.2.0 onward. You should use the new navigation manager if you are running 4.2.0

Boofo 05-23-2012 10:07 PM

How do you add sub-menus then that can't be added manually in the Navigation Manager?

Lynne 05-23-2012 10:15 PM

Quote:

Originally Posted by Boofo (Post 2332122)
How do you add sub-menus then that can't be added manually in the Navigation Manager?

I haven't looked into that and can't think why you wouldn't be able to add a sub-menu via the new Navigation Manager. I've added test sub-menus to my test site just fine using the new NM.

Boofo 05-23-2012 10:39 PM

True, but these sub-menus can't be done with the Navigation Manager as I use a vb:each setting to get the content for the menu and I see no way to add the ability to do that. If they are standard links, then yes, but not all menus are built the same, I guess. ;)

Badshah93 05-24-2012 01:13 PM

Quote:

Originally Posted by Boofo (Post 2332140)
True, but these sub-menus can't be done with the Navigation Manager as I use a vb:each setting to get the content for the menu and I see no way to add the ability to do that. If they are standard links, then yes, but not all menus are built the same, I guess. ;)

read this mate
https://vborg.vbsupport.ru/showpost....5&postcount=25

sub-menu, sub-links all can be added with just a plugin in vb 4.2.0 (no need to create template for navlinks)

Boofo 05-24-2012 01:31 PM

I read that and it confused me even more. LOL

TheSupportForum 06-01-2012 12:44 PM

can instructions be added for vBulletin 4.2

with the new Navigation Manager

How do i add a link using my existing MODS to auto add to the Navigation Manager

nhawk 06-01-2012 01:10 PM

Quote:

Originally Posted by simonhind (Post 2335417)
can instructions be added for vBulletin 4.2

with the new Navigation Manager

How do i add a link using my existing MODS to auto add to the Navigation Manager

A couple of different methods are discussed here...

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


All times are GMT. The time now is 02:31 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.02127 seconds
  • Memory Usage 1,913KB
  • 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
  • (16)bbcode_code_printable
  • (12)bbcode_php_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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