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)

thunderclap82 12-08-2009 03:15 AM

I'm sorry if I'm making this out to be more complicated than it needs to be, but I must be missing something. Here is your code from the first page:

PHP Code:

$tabselected '';
$tablinks '';
if (
THIS_SCRIPT == 'yourpage')
{
    
$vbulletin->options['selectednavtab']='unique_name';
    
$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="link.php">Nav Link</a>'.$tablinks.'</li>' 

I replaced 'yourpage' with 'podcast', and 'unique_name' with 'podcast'. I also changed the 'Nav Link' href and name at the bottom of the script to look like:

PHP Code:

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="/forums/content/116-podcast">Podcast</a>'.$tablinks.'</li>' 

It appears to me that these are the only changes required. What I don't understand is where I'm suppose to find the define('THIS_SCRIPT', '<name>');. You said it's at the top of the page, so I went to the actual podcast CMS page I created and looked at the Page Source in my browser but this code doesn't exist. So where is it located?

Lynne 12-08-2009 04:07 AM

THIS_SCRIPT is defined at the top of the php page, not some browser page, but in the actual code. Open up the file called forum.php that you downloaded from vbulletin.com to install on your server and you will see the line I am talking about.

I don't think (or rather, I don't know of the condition) you can do this for a CMS page. All those pages are using the content.php page and right now, if you are on a content.php page, the Home link is highlighted. I don't know what the condition is for a particular Article, which is what it sounds like you want to do. You'd have to look in through the code to figure that out and I haven't got that far into the CMS yet.

thunderclap82 12-08-2009 01:59 PM

So you're saying I do need to create a custom vBulletin page, and this NavBar technique can't work with a CMS created page, right?

Lynne 12-08-2009 02:04 PM

Quote:

Originally Posted by thunderclap82 (Post 1927271)
So you're saying I do need to create a custom vBulletin page, and this NavBar technique can't work with a CMS created page, right?

No, you don't need to create a custom page. That condition I posted is an EXAMPLE of a condition to use. Most people will use THIS_SCRIPT as the condition. But, you could use forumids or threadids or who-knows-what-else - as long as the condition is UNIQUE. And, I don't know that it won't work on a CMS created page. It probably could if you find the correct unique condition. I simply don't know what that condition would be since I haven't looked that closely into the CMS pages and the attributes that are passed to them.

Vaupell 12-15-2009 09:03 AM

1 Attachment(s)
Lovely it works like a charm, lynne to the rescue ;)

:D

I.am 12-16-2009 08:37 AM

It work in RC2?? because the selected function and the drop down menu doesn't appear for me.

Lynne 12-16-2009 03:33 PM

Quote:

Originally Posted by I.am (Post 1931568)
It work in RC2?? because the selected function and the drop down menu doesn't appear for me.

Worked fine for me in RC2 and in the current version, RC4.

I.am 12-16-2009 06:09 PM

on my RC2 the function selected doesn't work....

Lynne 12-16-2009 10:08 PM

Quote:

Originally Posted by I.am (Post 1931800)
on my RC2 the function selected doesn't work....

Then you probably don't have your condition written correctly, but from the (non-existant) information you've posted, it's hard to say.

I.am 12-17-2009 07:14 AM

This is what i use

PHP Code:

$tabselected '';
$tablinks '';
if (
THIS_SCRIPT == 'Downloads')
{
    
$vbulletin->options['selectednavtab']='Downloads_tab';
    
$tabselected ' class="selected"';
    
$tablinks '                <ul class="floatcontainer">
                        <li><a href="/resources/">Downloads</a></li>
                            <li class="popupmenu">
                                <a href="javascript://" class="popupctrl">Drop Down</a>
                                <ul class="popupbody popuphover">
                                        <li><a href="sublink1.php">Test Link 1</a></li>
                                        <li><a href="sublink2.php">Test Link 2</a></li>
                                        <li><a href="sublink3.php">Test Link 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="http://mysite.com/resources/">Downloads</a>'.$tablinks.'</li>' 

But when the page is selected the button doesn't work properly.

AndrewSpearin 12-17-2009 11:47 AM

I noticed someone else attempting to have the plugin work for multiple pages, they solved it but didn't share how they did so.

I am also attempting to have the same tab be highlighted for multiple pages (the ones linked in the navbar when you click on the tab), but can't seem to figure it out.

Any help would be much appreciated!

http://www.npac.ca/2010

Lynne 12-17-2009 03:23 PM

Quote:

Originally Posted by I.am (Post 1932101)
This is what i use

PHP Code:

$tabselected '';
$tablinks '';
if (
THIS_SCRIPT == 'Downloads')
{..... 

But when the page is selected the button doesn't work properly.

Is that condition valid? Do you have a line at the top of your downloads page that defines THIS_SCRIPT as "Downloads" (must use exact word - if capitalized in the php, then it must be capitalized in the condition).

Quote:

Originally Posted by AndrewSpearin (Post 1932180)
I noticed someone else attempting to have the plugin work for multiple pages, they solved it but didn't share how they did so.

I am also attempting to have the same tab be highlighted for multiple pages (the ones linked in the navbar when you click on the tab), but can't seem to figure it out.

Any help would be much appreciated!

http://www.npac.ca/2010

And are you conditions valid to make those tabs active?

AndrewSpearin 12-17-2009 06:40 PM

Oh actually they are not all set up just yet. It works as it should for 'Contests' - however I want Contests to remain highlighted when on the pages within that section.

From: http://npac.ca/2010/contests.php

Contests -> NPOY 2009 -> Information & Rules

Takes you to: http://npac.ca/2010/poy2009.php

Above is where I am working on first, and trying to figure out how to get it working for that page before moving on to the rest (which still need to be created).

This is my first time working with vBulletin, so am still getting used to conditions. I'm more of a designer than developer, but do have a firm understanding when it comes to the code.

I.am 12-17-2009 07:45 PM

Quote:

Originally Posted by Lynne (Post 1932299)
Is that condition valid? Do you have a line at the top of your downloads page that defines THIS_SCRIPT as "Downloads" (must use exact word - if capitalized in the php, then it must be capitalized in the condition).


And are you conditions valid to make those tabs active?

This is not a custom page, but it is a section of my community that i wat to show on navbar_tab.

Lynne 12-17-2009 09:20 PM

Quote:

Originally Posted by AndrewSpearin (Post 1932428)
Oh actually they are not all set up just yet. It works as it should for 'Contests' - however I want Contests to remain highlighted when on the pages within that section.

From: http://npac.ca/2010/contests.php

Contests -> NPOY 2009 -> Information & Rules

Takes you to: http://npac.ca/2010/poy2009.php

Above is where I am working on first, and trying to figure out how to get it working for that page before moving on to the rest (which still need to be created).

This is my first time working with vBulletin, so am still getting used to conditions. I'm more of a designer than developer, but do have a firm understanding when it comes to the code.

Then is sounds more like you should have a longer condition: if on Contests page or on poy2009 page or on xxxxx page. So, you could define THIS_SCRIPT at the top of each of those pages so you can use them in the condition:
PHP Code:

if (in_array(THIS_SCRIPT, array('contests''poy2009''xxxxx'))) 

You will NEED to define THIS_SCRIPT at the top of all those pages!!!!
PHP Code:

define('THIS_SCRIPT''xxxxx'); 

Quote:

Originally Posted by I.am (Post 1932471)
This is not a custom page, but it is a section of my community that i wat to show on navbar_tab.

Then you need to have a condition written to make that tab show for that section. I cannot help you with that as I am not that familiar with the CMS yet.

chsmith700 12-18-2009 05:52 AM

Lynne,

I am trying to set up a tab, and link it to a forum, basically a section kind like how Vbulletin.org has it. However, when I try to set an array on forums inside the sub, it wont highlight.

Here is my condition I have set.

Code:

if (in_array($forum['forumid'], array(13,22)))
--------------- Added [DATE]1261123033[/DATE] at [TIME]1261123033[/TIME] ---------------

Nevermind...lol figured it out.

If anyone else needs this the code is:
Code:

if (in_array($foruminfo['forumid'], array(13,22,35,19,24,59,60,93,94,36,61,62,21)))

AndrewSpearin 12-18-2009 02:09 PM

Thanks Lynne,

That condition you wrote did not work, but I found a simpler solution:

I simply defined THIS_SCRIPT as 'contests' in poy2009.php

Not sure if that will cause any conflicting problems, but it seems to be working fine.

MaryTheG(r)eek 12-27-2009 05:57 PM

Quote:

Originally Posted by Lionel (Post 1916454)
I looked but did not find the answer. How do you add a phrase in this code for Sublink 1?

<li><a href="sublink1.php">SubLink 1</a></li>

I tried ' . $vbphrase['my_phrase'] .'
I tried {vb:rawphrase my_phrase}

never mind ... I needed to globalize it

Try the first without ' ' in phrase. eg ' . $vbphrase[my_phrase] .'

Maria

Lionel 12-27-2009 06:18 PM

Quote:

Originally Posted by MicroHellas (Post 1939613)
Try the first without ' ' in phrase. eg ' . $vbphrase[my_phrase] .'

Maria

Hi,

Actually I had to

Quote:

global $vbphrase;

Kinneas 12-29-2009 12:17 PM

Thank you Lynne, this is extremely helpful :)

demojames 12-30-2009 08:44 PM

Thanks, Lynne! Worked perfectly for me with no issues.

Edit: One quick question, is there a way to use a condition to show the sublinks/dropdown links to just a certain usergroup? I tried a template condition, but that didn't work.

Lynne 12-30-2009 10:26 PM

Quote:

Originally Posted by demojames (Post 1942870)
Thanks, Lynne! Worked perfectly for me with no issues.

Edit: One quick question, is there a way to use a condition to show the sublinks/dropdown links to just a certain usergroup? I tried a template condition, but that didn't work.

I believe there are examples of how to do that on pages 2 and 4 of this thread.

demojames 12-30-2009 10:28 PM

Sorry about that, I just read the entire thread and saw that.

Thanks again

kersti 01-01-2010 11:25 AM

I just want to add in a simple link on the nav bar so I tried this and tried just removing the navlinks section of the code. The result was that my Blogs link disappeared and that was all.

What do I need to do to make this just a link on the nav bar to an external site (the add-on has problems and I'd prefer to have everything done "properly")

Lynne 01-01-2010 02:19 PM

There are mods to just add a simple link with no submenu. You are probably better off just using one of them.

Meje 01-02-2010 07:53 AM

Hello!

Ive read through the entire thread, and managed to get it all working by the end!! Thanks Lynne, for all your detailed replies, it really helped me to get it working.

Im stuck at one last thing though.......how do I get all the links in the sub menu to stay on the new tab when you click on them?

I have all my links in the sub menus going to VB Pages Ive created myself.

But when I click on each link, while it takes me to the new VB page Ive created, the tab and submenu returns to the Forum tab.

Ive played around with it a bit, but cant figure out how to make it work with multiple pages.....?

Please let me know if you need any additional info to help you understand what it is Im trying to do.

GRE 01-02-2010 08:51 AM

Is there a way to replace tabs with images?

MikeWarner 01-02-2010 09:36 AM

Great post Lynne! I'm not that great at hacks, but I managed to get this to work for a CMS news section. I thought others may want to know how to do this too. This is how I did it:

Copy the original vBulletin file "content.php" and save as "about.php" (or whatever filename you wish)

In your new about.php file Change:

Code:

define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'vbcms');

to
Code:

// define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'about_ridehub');

Ensure you comment out the first line as shown about, this stops the default CMS section links from showing in the lower area. I used "about_ridehub' for THIS_SCRIPT, but you can use anything you want, just make sure it is unique and set as per this How-To.

Upload your new .php file to forum root.

Make sure the CMS section you want this new nav bar to work with is "Not Published" otherwise Google will find duplicate content. This can be done in the Section Manager in the AdminCP.

Now instead of linking to (for example):
http://www.yoursite.co.uk/content.php/48-About

You can use:
http://www.yoursite.co.uk/about.php/48-About

Add these links to the menu bar, and it should all work ok.

See here for an example:
http://www.ridehub.co.uk/about.php/48-What-is-RideHub

Lynne 01-02-2010 03:29 PM

Quote:

Originally Posted by Meje (Post 1944743)
I have all my links in the sub menus going to VB Pages Ive created myself.

But when I click on each link, while it takes me to the new VB page Ive created, the tab and submenu returns to the Forum tab.

Ive played around with it a bit, but cant figure out how to make it work with multiple pages.....?

Please let me know if you need any additional info to help you understand what it is Im trying to do.

In the plugin code is a condition that sets when your tab is 'selected'. In my example I have this condition:
PHP Code:

if (THIS_SCRIPT == 'yourpage'

If you want it to stay highlighted for... say... all threads in forumids 11, 12, and 13 also, then you need to add in that condition:
PHP Code:

if (THIS_SCRIPT == 'yourpage' OR in_array($GLOBALS['forumid'], array(111213))) 

I'm not sure what your condition would be since you didn't really verbalize it, but I hope what I wrote helps.

Meje 01-02-2010 09:55 PM

1 Attachment(s)
Thanks for the reply Lynne.

I want the tab to stay selected, when I am on any of the pages in the submenu of the new tab.

Looks like it might be easier to show you the code? Its only going to make it easier for others trying to do the same thing to understand too :)

I have created a new tab called "Site Info'. I have also created my own VB page for it to link to.

This is the code for the plug in:

PHP Code:

$tabselected '';
$tablinks '';
if (
THIS_SCRIPT == 'ip_site_information')
{
    
$vbulletin->options['selectednavtab']='ip_site_information';
    
$tabselected ' class="selected"';
    
$tablinks '                <ul class="floatcontainer">
                        <li><a href="our_philosophy.php">Our Philosophy</a></li>
                            <li class="popupmenu">
                                <a href="javascript://" class="popupctrl">Advertising</a>
                                <ul class="popupbody popuphover">
                                        <li><a href="banner_advertising.php">Banner Advertising</a></li>
                                        <li><a href="sig_advertising.php">Signature Advertising</a></li>
                                    
                                </ul>
                            </li>
                        <li><a href="donations.php">Donations</a></li>
                        <li><a href="sendmessage.php.php">Contact Us</a></li>
                </ul> '
;


$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="ip_site_information.php">Site Info</a>'.$tablinks.'</li>' 

and this is the condition in my 'Site Info' VB page I created:

PHP Code:

define('THIS_SCRIPT''ip_site_information'); 

Everything works as it should with all the above code for the Site Info tab & Page.

I have 4 other VB pages I created myself. They are the the ones listed in the submenu of the new tab "Site Info' See first image attached.

For these 4 links in the submenu, the condition in each of their VB pages is as follows:

Our Philosophy Page:
PHP Code:

define('THIS_SCRIPT''our_philosophy'); 

Advertising is a drop down menu, so contains the 2 links, 'Sig Advertising' and 'Banner Advertising' that have their own VB pages.

Sig Advertising Page:
PHP Code:

define('THIS_SCRIPT''sig_advertising'); 

Banner Advertising Page:
PHP Code:

define('THIS_SCRIPT''banner_advertising'); 

Donations Page:
PHP Code:

define('THIS_SCRIPT''donations'); 

Now when I click on any of these links, you can see what happens in the second attached image, that while it takes me to the page I want it to, the tab thats selected is the Forum tab and all its submenus. Where as I want the new tab, 'Site Info' and all its submenus to remain selected when I click on these submenu links.

Lynne 01-02-2010 11:12 PM

Try this then (I think I got them all):
PHP Code:

if (in_array(THIS_SCRIPT ,array('ip_site_information''our_philosophy''sig_advertising''banner_advertising''donations'))) 


Meje 01-02-2010 11:44 PM

ahhhh!!! I was trying to figure out how to get them all in there! Works perfectly! Thank you!! :D

For anyone looking to do this, I have replaced this part of the plug in code:

PHP Code:

if (THIS_SCRIPT == 'ip_site_information'

With this from the post above:
PHP Code:

if (in_array(THIS_SCRIPT ,array('ip_site_information''our_philosophy''sig_advertising''banner_advertising''donations'))) 


MaryTheG(r)eek 01-03-2010 02:01 PM

Hello,

Why I can't add to the left side? I tried:
Code:

$template_hook['navtab_left']
but it didn't worked. Changing to 'navtab_middle' works fine. Actually I want to place it at very first (before Forums). Maybe I need to use a diffent hook place than process_templates_complete ?

Thank you
Maaria

Lynne 01-03-2010 02:07 PM

Quote:

Originally Posted by MicroHellas (Post 1945963)
Hello,

Why I can't add to the left side? I tried:
Code:

$template_hook['navtab_left']
but it didn't worked. Changing to 'navtab_middle' works fine. Actually I want to place it at very first (before Forums). Maybe I need to use a diffent hook place than process_templates_complete ?

Thank you
Maaria

You want navtab_start, not navtab_left. (There is no navtab_left.)

SuperGLS 01-03-2010 03:52 PM

So, after a bit of time reading a bunch of stuff in this thread (coupled with your HOW TO on adding pages) I've got this all figured out.

For the people that seem to be trying to grasp exactly what to do, it's probably best to follow this thread https://vborg.vbsupport.ru/showthread.php?t=228112 in order to create the link.php (or whatever you want to name it). Then everything else will make a lot more sense I think. Because then you'll actually have a webpage, that when you click on Nav Link, you'll be directed to and you'll be able to see the sublink and dropdown menus. After I did that up and read through the thread again it made a bit more sense. I hope that helps some people.

Lynne, you are great! Thanks again.

Because this is plugin form there won't be any problems when we update vB, right?

Lynne 01-03-2010 07:33 PM

Quote:

Originally Posted by SuperGLS (Post 1946082)
Because this is plugin form there won't be any problems when we update vB, right?

Unless they somehow screw up plugin locations or template_hook names or totally change the navbar or something like that, then this should be fine when you update vB.

SuperGLS 01-04-2010 01:34 AM

Thought so. Great! Template edits are just a pain to deal with that's why I love this plguin.

NJAquaman 01-04-2010 11:42 AM

Here is an Add-on i made to help the Nab Tab Drop Down Issues. Its a Easy Plugin code that can be Duplicated for another tab in the same Plugin!

https://vborg.vbsupport.ru/showthread.php?p=1946819

Let Me know If this Works!

Thanks!

OcR Envy 01-06-2010 08:53 PM

Quote:

Originally Posted by MikeWarner (Post 1944792)
Great post Lynne! I'm not that great at hacks, but I managed to get this to work for a CMS news section. I thought others may want to know how to do this too. This is how I did it:

Copy the original vBulletin file "content.php" and save as "about.php" (or whatever filename you wish)

In your new about.php file Change:

Code:

define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'vbcms');

to
Code:

// define('CMS_SCRIPT', true);
define('THIS_SCRIPT', 'about_ridehub');

Ensure you comment out the first line as shown about, this stops the default CMS section links from showing in the lower area. I used "about_ridehub' for THIS_SCRIPT, but you can use anything you want, just make sure it is unique and set as per this How-To.

Upload your new .php file to forum root.

Make sure the CMS section you want this new nav bar to work with is "Not Published" otherwise Google will find duplicate content. This can be done in the Section Manager in the AdminCP.

Now instead of linking to (for example):
http://www.yoursite.co.uk/content.php/48-About

You can use:
http://www.yoursite.co.uk/about.php/48-About

Add these links to the menu bar, and it should all work ok.

See here for an example:
http://www.ridehub.co.uk/about.php/48-What-is-RideHub


This works until you click on a category or article then it reverts back to selecting home. Any idea on a fix?

MikeWarner 01-07-2010 07:41 AM

Yeah - the items listed within the main page body do refer back to the original php file. I'm trying to think of a way around this. I'll post when I figure it out.


All times are GMT. The time now is 04:43 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.02276 seconds
  • Memory Usage 1,918KB
  • 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
  • (8)bbcode_code_printable
  • (17)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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