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)

ragtek 11-17-2009 10:00 PM

[HOW TO - vB4] Create a New Tab in the navbar (with template)
 
1 Attachment(s)
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'">

taffy056 11-18-2009 06:07 PM

Can I ask where do you place the plugin?

In truth I am getting a bit lost with this, why can't the CMS simply place links where you want them, I like subdreamer's way of doing this I think!

ragtek 11-18-2009 06:16 PM

Sorry, strange that it's gone away. I've edited my post;)

And the hook is process_templates_complete

LoveStream 11-19-2009 12:33 AM

Quote:

Originally Posted by ragtek (Post 1916742)
Sorry, strange that it's gone away. I've edited my post;)

And the hook is process_templates_complete

Thank you. I hope it. :)

Hoagie 11-20-2009 11:10 PM

1 Attachment(s)
Man this is awesome. When I am displaying the page I created the forums tab is still highlighted....am I missing something or did I forget to change something.....

Thanks for the help!

ragtek 11-21-2009 05:56 AM

whats your code?

Hoagie 11-21-2009 01:25 PM

Which code? The plugin code?

ragtek 11-21-2009 02:40 PM

Plugin and template code

VonDoom 11-21-2009 02:59 PM

Very cool and simple, thanks for this.

Hoagie 11-21-2009 03:18 PM

Plug In Code:
Code:

$tabselected = '';
$tablinks = '';
if (THIS_SCRIPT == 'member_ranks')
{
    $vbulletin->options['Ranks']='unique_name';
    $tabselected = ' class="selected"';

}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="ranks.php">Ranks</a>'.$tablinks.'</li>' ;

Template Code:
Code:

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
   
    {vb:raw header}
   
    {vb:raw navbar}
   
    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>
   
    <h2 class="blockhead">=MK= Member Ranks</h2>
    <div class="blockbody">
      <div class="blockrow">

<div>
MY CUSTOM CODE WENT HERE ( Removed to save some space)
  </div>
</div>

      </div>
    </div>
   
    {vb:raw footer}
  </body>
</html>



All times are GMT. The time now is 03:10 PM.

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.01390 seconds
  • Memory Usage 1,742KB
  • 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
  • (2)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)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
  • (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