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?


All times are GMT. The time now is 10:46 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.01479 seconds
  • Memory Usage 1,805KB
  • 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
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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