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 (with template) (https://vborg.vbsupport.ru/showthread.php?t=228313)

ultimategeek 09-21-2011 01:56 PM

Quote:

Originally Posted by ragtek (Post 1916710)
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?

davis31b 12-09-2011 08:06 AM

1 Attachment(s)
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?

Lynne 12-09-2011 04:12 PM

Quote:

Originally Posted by davis31b (Post 2276130)
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';
}


davis31b 12-09-2011 10:23 PM

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.

nasko 12-10-2011 07:25 AM

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 ?

Lynne 12-10-2011 05:36 PM

Quote:

Originally Posted by davis31b (Post 2276399)
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 (Post 2276455)
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?

Dax IX 12-10-2011 09:42 PM

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

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

Assopoker 01-27-2012 11:59 AM

the better the more complex ?

Dax IX 01-27-2012 02:15 PM

Best way possible, please. :)

Nocturnal222 04-02-2012 06:12 AM

is this safe? no security holes?

Lynne 04-02-2012 03:39 PM

Quote:

Originally Posted by Nocturnal222 (Post 2315933)
is this safe? no security holes?

The code posted in the first post is perfectly safe. You will need to make sure that all php code that you add yourself has no security holes if you add any.

Winter Sonata 05-14-2012 07:21 AM

How can I control the order of the tabs?

ragtek 05-14-2012 11:33 AM

Quote:

Originally Posted by Winter Sonata (Post 2329210)
How can I control the order of the tabs?

with the template hook names (check template navbar to see all available hooks) and the plugin execution order

Dave234 05-22-2012 02:25 PM

I copied and pasted the codes exactly as you have them ragteknews, and I got the tab on there, but it is blank. Also when I click it, it goes to a nonworking page. How can I label the tab "User Photos" and have it go to a gallery of random user photos?

Christos Teriakis 05-22-2012 02:51 PM

Pitty, but seems that is not working with vB4.2. I'm not getting any error when I'm importing the product file, but there is no Tab in the bar.

Chris

tiger 07-29-2013 12:03 AM

Anyone know how to make this work in 4.2?

Lynne 07-29-2013 01:19 AM

4.2.1 has a Navigation Manager to do this without using this article.

Easy5s.net 07-29-2013 11:09 PM

Can user this for auto add tabs when write plugin?


All times are GMT. The time now is 01:25 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02341 seconds
  • Memory Usage 1,836KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_html_printable
  • (2)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)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