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)

duvik 04-10-2010 03:48 PM

This was very useful, thanks much.

Just a little thing I noticed while searching for something related to this tutorial...

** link removed **

Seems to be very familiar... word for word with no credit given in fact... how rude!

Lynne 04-10-2010 04:16 PM

Sorry, we don't like links to that site. However, I'm not surprised to see this there - that is what they do - copy, copy, copy, with no credit and no permission.

Mythotical 04-15-2010 05:10 PM

Ok I tried Cellarius' change for using with the CMS. Here is my code:
PHP Code:

if (in_array($this->content->getNodeId(), array(147,152,153))) 

Error:
Quote:

Fatal error: Call to a member function getNodeId() on a non-object in includes/class_bootstrap.php(399) : eval()'d code on line 3

Lynne 04-16-2010 12:25 AM

Cellarius' change doesn't work in 4.0.3 any longer. I haven't looked into it to see what works now.

mikey1991 04-16-2010 01:30 AM

Seems like getNodeId is deprecated in 4.0.3?

Mythotical 04-16-2010 01:31 AM

I'll do some testing and playing with, if I find a solution I will post it for all to use.

Yonatan 04-16-2010 12:42 PM

Try using $_GET to detect the section.

you can using this example:
PHP Code:

$tabselected '';
$tablinks '';

if ((
$_GET['r'] == 10) && (THIS_SCRIPT == 'vbcms'))  
{
    
$vbulletin->options['selectednavtab']='content.php?r=10';
    
$tabselected ' class="selected"';
    
$tablinks '';

}

$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?r=10">Tab Name</a>'.$tablinks.'</li>' 


Lynne 04-16-2010 01:44 PM

Quote:

Originally Posted by Yonatan (Post 2022156)
Try using $_GET to detect the section.

Oh yeah, I forgot about that one. Thanks.

alfanexus 04-16-2010 02:13 PM

Quote:

Originally Posted by Yonatan (Post 2022156)
Try using $_GET to detect the section.
....

Yes this will help if you have selected the section main page, but it still wont work if you select an article inside a section becaurse "r" then will relate to the article and not the section.

I have the same problem, and got a good answer at vbulletin.com (although I dident get the solution to work) Here is the link: http://www.vbulletin.com/forum/showt...code&p=1964854

Yonatan 04-16-2010 02:57 PM

Quote:

Originally Posted by alfanexus (Post 2022201)
Yes this will help if you have selected the section main page, but it still wont work if you select an article inside a section becaurse "r" then will relate to the article and not the section.

I have the same problem, and got a good answer at vbulletin.com (although I dident get the solution to work) Here is the link: http://www.vbulletin.com/forum/showt...code&p=1964854

I know it.

But for now, It's better than nothing ;)

Mythotical 04-22-2010 02:15 AM

Using $_GET['r'] isn't working. It will still have the Home tab and the new tab highlighted with both overlapping each other for sub links.

arilukes 04-26-2010 12:49 AM

This works perfectly and is a very easy to understand tutorial on how to create a new tab. I had no problems whatsoever in implementing this.

Thank you so much

Mythotical 04-26-2010 04:36 PM

Ok Yonatan's suggestion didn't work on 4.0.3 PL1. It is causing Home and my tab to be highlighted with all subsections from both displaying.

Lynne 04-26-2010 06:29 PM

Quote:

Originally Posted by Steve M (Post 2027696)
Ok Yonatan's suggestion didn't work on 4.0.3 PL1. It is causing Home and my tab to be highlighted with all subsections from both displaying.

How did you modify the condition for the submenu for the Home tab? If you don't modify it, it will always show as long as you are in the vbcms area since that is how the condition is written.

arilukes 04-28-2010 06:07 AM

I guess the code doesn't work for anything child level including subsections. I used $_GET and put all of my sections and subsections in an array in the vbcms, but only the top level sections will show the tab as hightlighted with the proper subnavbar below. If I click on a subsection, the correct tab stays highlighted, but the subnavbar selections disappear.

This is what I am using in the vbcms

PHP Code:

<vb:if condition="$vboptions['selectednavtab'] == 'vbcms' AND !in_array($_GET['r'], array(181,182,183,184,185,186,187,188,189,190,199,200,201,202,203,210,211,212,213,214,215,216,217,218,219,220,221,222))"

I tried using this in my tab plug-in to see if this fixed the issue

PHP Code:

if (((in_array($_GET['r'], array(181,182,183,184,185,186,187,189,190)) && (THIS_SCRIPT == 'vbcms'))) 

but I get this error

Parse error: syntax error, unexpected '{' in /data/22/2/56/92/2056418/user/2253608/htdocs/forumsbb/includes/class_bootstrap.php(399) : eval()'d code on line 14

Lynne 04-28-2010 01:40 PM

Count your ( and ) - they don't add up, which is why you got the error.

arilukes 04-28-2010 10:18 PM

Yup that was totally it. Thanks!

aaronater 04-29-2010 01:12 PM

Hi, this thread is very long and I'm still quite new to vB but have experience in developing. Is there a tutorial somewhere that shows you how to create the new sections and how to have the navbar tabs link to them all in one?

Thanks.

Lynne 04-29-2010 01:45 PM

Quote:

Originally Posted by aaronater (Post 2029009)
Hi, this thread is very long and I'm still quite new to vB but have experience in developing. Is there a tutorial somewhere that shows you how to create the new sections and how to have the navbar tabs link to them all in one?

Thanks.

Create Sections? Like in the CMS? There are a bunch of articles on vb.com about the CMS. And when you create a section, you may select the option to put the link in the subnavmenu. You can read the articles about this.

aaronater 04-29-2010 02:20 PM

Hi,

Thanks, the thing is when I search 'create new section' or 'create section' I do not get any returns of any interset. I have tried searching but find lots of really basic stuff but not how to create new sections, I might be confused.

Basically I want to create a new tab called 'Contacts' which will link to a page with lists of names and contact details. It's straight forward how to add the tab but what about the pages of content to go along with it?

I understand the code you pasted originally and conditions.

In section manager I can only add sections to 'Home' I want to create a section to be linked to the new tab 'Contacts'

Lynne 04-30-2010 02:23 AM

I can't tell whether you are talking about the CMS or not. If so, the place you should look for documentation is on vb.com > click the Home tab there and read all the articles about it.

If you are simply talking about adding another page and then linking to that page with a navtab, then this is the article to create the navtab, and if you look at my profile, you will find the article to create your own custom pages.

darsalles 05-01-2010 09:26 PM

Hi there Im having a small problem... the tab creates sucesfully but when I click on it and enter the section, the navbar selected it still on "Forum" instead of the section I want.

How could I change this D:??

Lynne 05-01-2010 09:45 PM

Quote:

Originally Posted by darsalles (Post 2030322)
Hi there Im having a small problem... the tab creates sucesfully but when I click on it and enter the section, the navbar selected it still on "Forum" instead of the section I want.

How could I change this D:??

You need to have the condition set correctly for your tab to show as 'active'. What condition are you using?

Jonas Clark 05-03-2010 06:34 PM

I want to use this to put navlinks before the Home tab and then rename the hometab to CMS or Community.

How do I do this?

Thanks

Lynne 05-03-2010 11:01 PM

Make sure you pick the appropriate template_hook location to put the tab before the Home tab. You may have to change the order on it to put it before or after the Home tab.

Jonas Clark 05-04-2010 02:07 PM

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

Quote:

Originally Posted by Lynne (Post 2031389)
Make sure you pick the appropriate template_hook location to put the tab before the Home tab. You may have to change the order on it to put it before or after the Home tab.

Hi Lynne,

I'm a complete novice... can you show me how?
I used $template_hook['navtab_start']

Lynne 05-04-2010 05:22 PM

Quote:

Originally Posted by Jonas Clark (Post 2031632)
--------------- Added 04 May 2010 at 08:10 ---------------


Hi Lynne,

I'm a complete novice... can you show me how?
I used $template_hook['navtab_start']

OK, and what was the result? And have you tried changing the execution order of the plugin?

Jonas Clark 05-05-2010 04:49 PM

So the executing order is 5, should it be 1? If so... how do I rename Home (for the CMS frontpage tab) to Articles?

Lynne 05-05-2010 06:10 PM

Quote:

Originally Posted by Jonas Clark (Post 2032204)
So the executing order is 5, should it be 1? If so... how do I rename Home (for the CMS frontpage tab) to Articles?

Try 1 and see.

Edit the phrase "site" to change "Home"

mclarens 05-07-2010 10:16 PM

Hey Lynne, great tread, can finaly add links to my nav bar.

This might be abit offtopic but, i was thinking to change my "Home" button on the navbar to another side and been searching around without no exacly explainable answer how to to do that.
Do you know how to do that or where i can find the answer on that? :)

Lynne 05-07-2010 10:27 PM

Quote:

Originally Posted by mclarens (Post 2033440)
Hey Lynne, great tread, can finaly add links to my nav bar.

This might be abit offtopic but, i was thinking to change my "Home" button on the navbar to another side and been searching around without no exacly explainable answer how to to do that.
Do you know how to do that or where i can find the answer on that? :)

Just change the template_hook it is using. Plugin - Navbar: Insert CMS Navbar Entry

mclarens 05-08-2010 09:16 AM

ahh thanks alot :)

mordor1 05-10-2010 04:42 PM

I got it working for 1 link but now i want to make one for the FAQ too

Code:

Plugin PHP Code
$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'faq.php')
{
    $vbulletin->options['selectednavtab']='faq_ftn';
    $tabselected = ' class="selected"';
    $tablinks = '                <ul class="floatcontainer">
                        <li><a href="faq.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="faq.php">FAQ</a>'.$tablinks.'</li>' ;

The link Faq is not highlighted now when its selected

Lynne 05-10-2010 07:33 PM

This is not valid for the faq page:
PHP Code:

if (THIS_SCRIPT == 'faq.php'

Open the file faq.php and find what THIS_SCRIPT is defined to be at the top.

Jonas Clark 05-10-2010 09:25 PM

Thanks Lynne, Everything worked great... execution controls order of tab.

mordor1 05-11-2010 05:46 PM

Quote:

Originally Posted by Lynne (Post 2034695)
This is not valid for the faq page:
PHP Code:

if (THIS_SCRIPT == 'faq.php'

Open the file faq.php and find what THIS_SCRIPT is defined to be at the top.

thx its faq without .php .... :o

Bansheebob 05-18-2010 04:57 PM

I cant believe we have to go through all this to add simple links to a navbar. What the hell? I dont know how to do all this. Make my own plugin, your kidding right? Now I'm gonna have to pay someone to add a few links to my navbar, unlike 3.8 where it was as easy as a simple template edit/addition. Unreal. I'm starting to see why people are going back to the old vb forums.

cellarius 05-18-2010 05:04 PM

Quote:

Originally Posted by Bansheebob (Post 2039342)
I cant believe we have to go through all this to add simple links to a navbar. What the hell? I dont know how to do all this. Make my own plugin, your kidding right? Now I'm gonna have to pay someone to add a few links to my navbar, unlike 3.8 where it was as easy as a simple template edit/addition. Unreal. I'm starting to see why people are going back to the old vb forums.

I can understand your frustration, but a thread where a volunteer took the time to explain what is clearly too difficult is not the place to vent, really. Lynne or her tutorial are not to be blamed for this.

Bansheebob 05-18-2010 05:07 PM

I wasnt blaming Lynne, she actually helped me yesterday with another issue. Just frustrated because on 3.8 I could edit anything in templates very easily and now in vb4 it's like you need a college course. They say in another thread "find this code" in navbar template and I look and its not even there in my code. I cant win today, starting to dislike vb4 bigtime.

Wilfred1 05-19-2010 11:31 PM

Lynne - thank you for this and I have played around with it and with some small changes to suit my needs it works well.

But I would like to add that I am having an issue with this whole new navbar setup for v4 especially given that the navbar is the most changed component, in my opinion, in vb.

I use a navbar that is very similar to the new v4 one except with the added functionality of being able to hover on a tab and access the submenu of that tab for a set millisecond time before it bounces back to the currently selected tab.

To do this I have to set the criteria for its use when using v3.8.5:
Code:

<script type="text/javascript">
    <if condition="in_array(THIS_SCRIPT, array('adv_index', 'about', 'sendmessage','support','staff','memberlist','online', 'private', 'register'))">tabmenu.definemenu("menu", 0)</if>
    <if condition="in_array(ADV_DYNA_PREFIX, array('aircraft', 'acnotice'))">tabmenu.definemenu("menu", 1)</if>
    <if condition="in_array(THIS_SCRIPT, array('aircraft_register', 'aircraft_types'))">tabmenu.definemenu("menu", 1)</if>
    <if condition="in_array(THIS_SCRIPT, array('blog', 'blog_usercp'))">tabmenu.definemenu("menu", 2)</if>
    <if condition="in_array(ADV_DYNA_PREFIX, array('clubs', 'download', 'terms'))">tabmenu.definemenu("menu", 3)</if>
    <if condition="in_array(THIS_SCRIPT, array('calendar', 'view', 'vbgooglemaphse', 'links_index', 'quiz', 'weather', 'weather_arfor', 'weather_metar', 'weather_taf', 'weather_sigmet', 'flight_planner'))">tabmenu.definemenu("menu", 3)</if>
    <if condition="in_array(THIS_SCRIPT, array('index', 'album', 'group', 'search', 'showthread', 'forumdisplay', 'newthread'))">tabmenu.definemenu("menu", 4)</if>
    <if condition="in_array(ADV_DYNA_PREFIX, array('quotes'))">tabmenu.definemenu("menu", 5)</if>
    <if condition="in_array(THIS_SCRIPT, array('arcade', 'gallery_index', 'gallery_upload', 'gallery_search', 'gallery_slideshow', 'gallery_albums', 'gallery_edit', 'gallery_delete', 'vbtubepro', 'youtube_browser'))">tabmenu.definemenu("menu", 5)</if>
    <if condition="in_array(THIS_SCRIPT, array('profile', 'member', 'subscription'))">tabmenu.definemenu("menu", 6)</if>
    <if condition="ADV_DYNA_PREFIX == 'classifi'">tabmenu.definemenu("menu", 8)</if>
    <if condition="$pg=='advertising_rates'">tabmenu.definemenu("menu", 0)</if>
</script>

Following this criteria are all the different sub menus which are listed as ul and li's.

As you can see it is a "dogs breakfast" of an array and trying to convert this to a more vb way using your great tutorial here is really, for me, going from one "dog's breakfast" to another.

So I raise this question...there must be a better way for everyone to manage their v4 navbar?

Could a global variable be created and:
- each time a user clicks a tab or submenu item the global variable is set to a number to correspond to the tab id
- the page changes to the linked page
- the tab that corresponds to the global variable is then made "selected"

Very little code would be needed to facilitate this, you wouldn't need to worry about "THIS SCRIPT" or any other definition of what page is being displayed, very simple to include a setting of the global variable on clicking, and then reading the variable on page display etc.

Is this an option? Would it make the navbar easier to manage? Would it improve performance? :confused:


All times are GMT. The time now is 07:04 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.01848 seconds
  • Memory Usage 1,865KB
  • 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
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (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