Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles

Reply
 
Thread Tools
[HOW TO - vB4] Create a New Tab in the navbar (with template)
ragtek
Join Date: Mar 2006
Posts: 1,630

 

austria, croatia
Show Printable Version Email this Page Subscription
ragtek ragtek is offline 11-17-2009, 10:00 PM

I know that lynne allready postet an article, but here's a other way:

This tutorial will show you, how to add own links to your navbar.
(In the tutorial i'll use the code for my news add-on)


1. create a template (ragtek_news_navbar)
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
<li class="selected">
    <a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
</vb:if>
2. Create a plugin at the hook process_templates_complete
PHP Code:
if (THIS_SCRIPT == 'xxx')  // also defined('ragteknews') possible
{
//set selected tab
    
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render(); 
As you see, i've defined "ragteknews" on my news.php page.If ragteknews is defined, $vbulletion->options['selectednavtab'] will be set to ragteknews.
Thats important because where using a condition in the template:
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
Attached Images
File Type: png Forums_1258596385528.png (7.9 KB, 0 views)
File Type: png Forums - News_1258596373538.png (11.1 KB, 0 views)
Reply With Quote
  #82  
Old 09-21-2011, 01:56 PM
ultimategeek ultimategeek is offline
 
Join Date: Sep 2011
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
I know that lynne allready postet an article, but here's a other way:

This tutorial will show you, how to add own links to your navbar.
(In the tutorial i'll use the code for my news add-on)


1. create a template (ragtek_news_navbar)
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
<li class="selected">
    <a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a>
<ul class="floatcontainer">
<li><a href="#">#</a></li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
</vb:if>
2. Create a plugin at the hook process_templates_complete
PHP Code:
if (THIS_SCRIPT == 'xxx')  // also defined('ragteknews') possible
{
//set selected tab
    
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render(); 
As you see, i've defined "ragteknews" on my news.php page.If ragteknews is defined, $vbulletion->options['selectednavtab'] will be set to ragteknews.
Thats important because where using a condition in the template:
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
Hi, very new to this so i have to ask, where do you do this?
Reply With Quote
  #83  
Old 12-09-2011, 08:06 AM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Everything turns out good.. just have one issue (see screenshot).. I added both tabs, "auction" & "news". When I click news, only the news tab is selected which is what it is supposed to do, however when i select auction, both news & auction are selected..

very strange, any ideas?
Attached Images
File Type: jpg error.jpg (27.8 KB, 0 views)
Reply With Quote
  #84  
Old 12-09-2011, 04:12 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by davis31b View Post
Everything turns out good.. just have one issue (see screenshot).. I added both tabs, "auction" & "news". When I click news, only the news tab is selected which is what it is supposed to do, however when i select auction, both news & auction are selected..

very strange, any ideas?
Is this part unique for each?
Code:
if (THIS_SCRIPT == 'xxx')  // also defined('ragteknews') possible 
{ 
//set selected tab 
    $vbulletin->options['selectednavtab'] = 'ragteknews'; 
} 
Reply With Quote
  #85  
Old 12-09-2011, 10:23 PM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I have made sure that neither plugins or templates has anything similar, each are using unique templates and plugins.

When I click the "Auction" link both are selected, but when I click "New" only news is selected, so I was thinking that something was wrong with the auction template or plugin, but I can't find anything wrong since it was not unique. Thanks.
Reply With Quote
  #86  
Old 12-10-2011, 07:25 AM
nasko nasko is offline
 
Join Date: Sep 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I red the entire thread but didn`t find solution for my problem.

The tab is successfully displayed on my forum navbar, but when I am on the homepage which is CMS I don`t see my new tab, only the default ones: Home, Forum, Blogs, What's New?

Any help ?
Reply With Quote
  #87  
Old 12-10-2011, 05:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by davis31b View Post
Yes, I have made sure that neither plugins or templates has anything similar, each are using unique templates and plugins.

When I click the "Auction" link both are selected, but when I click "New" only news is selected, so I was thinking that something was wrong with the auction template or plugin, but I can't find anything wrong since it was not unique. Thanks.
You'll need to post your code for both so we can see it.

Quote:
Originally Posted by nasko View Post
Ok, I red the entire thread but didn`t find solution for my problem.

The tab is successfully displayed on my forum navbar, but when I am on the homepage which is CMS I don`t see my new tab, only the default ones: Home, Forum, Blogs, What's New?

Any help ?
Are you using a different style on the CMS section?
Reply With Quote
  #88  
Old 12-10-2011, 09:42 PM
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Posts: 153
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent tutorial!

I have a question about using this with vBa CMPS...I'd like the subnav links to be the various pages of my vBa CMPS. Basically I want the links in the Site Navigation module to show in my navbar.

I've pieced a few things together, but obviously I've done something horribly wrong as they aren't working...

I basically just copied and pasted code, so some of this code is not playing well with other parts. I just need to figure out where I need to change things...

Here's my plugin code:
PHP Code:
$navigationbits = array();

if (!empty(
$vbulletin->adv_portal_page))
{
    
$navpages array_keys($vbulletin->adv_portal_page);
}

if (!empty(
$mod_options['portal_navigation_excludepages']))
{
    
$navpages array_diff($navpages$mod_options['portal_navigation_excludepages']);
}

(
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_start')) ? eval($hook) : false;

if (!empty(
$navpages))
{
    eval(
'$mod_options[\'portal_navigation_mark1\'] = "' addslashes($mod_options['portal_navigation_mark1']) . '";');
    eval(
'$mod_options[\'portal_navigation_mark2\'] = "' addslashes($mod_options['portal_navigation_mark2']) . '";');

    foreach (
$navpages AS $npageid)
    {
        
$npage =& $vbulletin->adv_portal_page[$npageid];

        if (!
array_intersect($vbulletin->userinfo['usergrouparray'], $npage['userperms']))
        {
            continue;
        }

        if (
$npage['level'] <= 1)
        {
            
$navigationbits[$npageid]['navmark'] = $mod_options['portal_navigation_mark1'];
        }
        else
        {
            
$navigationbits[$npageid]['navmark'] = str_repeat('&nbsp;', (intval($npage['level'] - 1))) . $mod_options['portal_navigation_mark2'];
        }

        
$navigationbits[$npageid]['link'] = $vba_options['portal_homeurl'] . ($npage['name'] != 'home' '?' $vbulletin->session->vars['sessionurl'] . $vba_options['portal_pagevar'] . '=' $npage['name'] : '');
        
$navigationbits[$npageid]['title'] = ($npageid == $pages['pageid']) ? '<strong>' $npage['title'] . '</strong>' $npage['title'];

        (
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_def_pagebits')) ? eval($hook) : false;
    }
}

// Additional pages
$customnavigationbits = array();

if (!empty(
$mod_options['portal_navigation_addpages']))
{
    foreach (
$mod_options['portal_navigation_addpages'] AS $key => $navlinks)
    {
        
$customnavigationbits[$key]['title'] = $navlinks['text'];
        eval(
'$customnavigationbits[$key][\'link\'] = "' addslashes($navlinks['link']) . '";');

        if (
$navlinks['level'] <= 1)
        {
            
$customnavigationbits[$key]['navmark'] = $mod_options['portal_navigation_mark1'];
        }
        else
        {
            
$customnavigationbits[$key]['navmark'] = str_repeat('&nbsp;'intval($navlinks['level'] - 1)) . $mod_options['portal_navigation_mark2'];
        }

        (
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_cus_pagebits')) ? eval($hook) : false;
    }
}

(
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_end')) ? eval($hook) : false;

$templater vB_Template::create('portal_navbar');
$templater->register('customnavigationbits'$customnavigationbits);
$templater->register('navigationbits'$navigationbits);
$home["$mods[modid]"]['content'] = $templater->render();


if (
THIS_SCRIPT == 'adv_index')  // also defined('ragteknews') possible
{
//set selected tab
    
$vbulletin->options['selectednavtab'] = 'portal';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_start'] .= vB_Template::create('portal_navbar')->render(); 
(with parts taken directly from the navigation.php module code)

and my template code:
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'portal'">
<li class="selected">
    <a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a>
<ul class="floatcontainer">
    <vb:each from="navigationbits" value="page">
        <li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
    </vb:each> 
       <vb:each from="customnavigationbits" value="page">
        <li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
    </vb:each></ul>
</li>
<vb:else />
<li><a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a></li>
</vb:if>
(with parts taken from the adv_portal_navigation template)

Where am I going wrong?
(I'm obviously NOT a coder...)
Reply With Quote
  #89  
Old 01-27-2012, 11:59 AM
Assopoker Assopoker is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the better the more complex ?
Reply With Quote
  #90  
Old 01-27-2012, 02:15 PM
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Posts: 153
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Best way possible, please.
Reply With Quote
  #91  
Old 04-02-2012, 06:12 AM
Nocturnal222 Nocturnal222 is offline
 
Join Date: Dec 2006
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is this safe? no security holes?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:40 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.04632 seconds
  • Memory Usage 2,390KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (5)bbcode_html
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (4)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (3)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete