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>


Anseur 11-21-2009 09:32 PM

Is your templace called "member_ranks" or something else?

Hoagie 11-22-2009 01:33 AM

Its called vbcms_ranks

Please tell me its not that simple.......I knew it would be something simple I was over looking...

Zaiaku 11-22-2009 10:32 PM

Perfect! I didn't want to have to edit the files especially since its in beta.

ragtek 11-23-2009 04:47 AM

Quote:

Originally Posted by Hoagie (Post 1918365)
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>


And what's with the template for the navbar?
I think you made it completely false

Hoagie 11-23-2009 04:38 PM

vbcms_navbar_add
Code:

<vb:if condition="$vboptions['selectednavtab'] == 'Ranks'">
<li class="selected">
  <a class="navtab" href="ranks.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
<vb:else />
</vb:if>


ragtek 11-24-2009 04:27 AM

Try this:
PHP Code:

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


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

You have to set $vbulletin->options['selectednavtab'] because if it's empty vbulletin sets the forum to standard and then you have 2 "active tabs"

Hoagie 11-25-2009 01:45 PM

1 Attachment(s)
That didnt work.........

but it did add a light gray line at the top of the page....

kingMOB 11-26-2009 05:23 PM

Hi ragtek, thanks for the code, will use it later =)

Right now I'm trying to do something a little differente: create a tertiary navbar just below the sections navbar for the CMS page. In this tertiary navbar wil be listed the subsections for the sections in the navbar. So if there's a section named "Music" in the navbar, when clicked, the tertiary navbar wil show the subsections from "Music". It's almost the same as the Section Navigation Widget, but in the navbar and without all that java =)

Is this possible, and, how? =)

Thank you =)

ragtek 11-26-2009 05:51 PM

Quote:

Originally Posted by kingMOB (Post 1921308)
Hi ragtek, thanks for the code, will use it later =)

Right now I'm trying to do something a little differente: create a tertiary navbar just below the sections navbar for the CMS page. In this tertiary navbar wil be listed the subsections for the sections in the navbar. So if there's a section named "Music" in the navbar, when clicked, the tertiary navbar wil show the subsections from "Music". It's almost the same as the Section Navigation Widget, but in the navbar and without all that java =)

Is this possible, and, how? =)

Thank you =)

phuuuuuuu, very good question, but i don't know how to make it
sorry

ndL 11-27-2009 07:26 PM

please post "news.php" content, because i cant find how to make a selectednavtab, did what you have said, but it still doesnt work!

Adem GEN? 11-29-2009 12:11 AM

Hi,

https://vborg.vbsupport.ru/showthread.php?t=228112
A test.php page I've created here

New tab is not selected TEST

My bad English

For test.php please tell me?

Regards

ragtek 11-29-2009 08:32 AM

Quote:

Originally Posted by AdemGEN? (Post 1922262)
Hi,

https://vborg.vbsupport.ru/showthread.php?t=228112
A test.php page I've created here

New tab is not selected TEST

My bad English

For test.php please tell me?

Regards

what?

Adem GEN? 11-29-2009 08:55 AM

Like this https://vborg.vbsupport.ru/attachmen...8&d=1258596456

I click new tab TEST
test.php page opens
But
Forum tab will be selected

Lynne 11-29-2009 02:04 PM

Quote:

Originally Posted by AdemGEN? (Post 1922403)
Like this https://vborg.vbsupport.ru/attachmen...8&d=1258596456

I click new tab TEST
test.php page opens
But
Forum tab will be selected

Reread part 2 of the article:
Quote:

As you see, i've defined "ragteknews" on my news.php page.If ragteknews is defined, $vbulletion->options['selectednavtab'] will be set to ragteknews.

steven s 11-29-2009 02:36 PM

Sorry, this may very obvious, but why is there a condition?
I would want the tab to be visible whether I am viewing the CMS, Blog or forum.

EDIT: As it is always with me, I understand it a little more after posting a questions and rereading the original post.
Is the condition for when the link is selected, do some action, like go to that link?

EDIT2: How do I put a name on the tab? Do I create a phrase?
Is there anything wrong with me replacing {vb:rawphrase ragtek_news} with my tab name?

Lynne 11-29-2009 03:43 PM

The condition is for when that tab is 'active' and the submenu shows.

steven s 11-29-2009 04:47 PM

Quote:

Originally Posted by Lynne (Post 1922552)
The condition is for when that tab is 'active' and the submenu shows.

Ah. Similar to your new tab in nav bar?
I'm just looking to add a tab when clicked goes to another page.

Lynne 11-29-2009 04:57 PM

Quote:

Originally Posted by 1996 328ti (Post 1922592)
Ah. Similar to your new tab in nav bar?
I'm just looking to add a tab when clicked goes to another page.

Yes, my mod and ragtek's do the same thing. We happened to each write them using a different approach to do the same thing. :)

pokash 11-29-2009 08:52 PM

Could someone show this noob how for example I could create 2 tabs each linking to an url? I don't understand what exactly I need to do.

Hoagie 11-30-2009 11:51 AM

any word on my issues? post #17 and the forum tab selected instead of the "Ranks" page???

ndL 11-30-2009 04:10 PM

Quote:

Originally Posted by Lynne (Post 1922503)
Reread part 2 of the article:

sorry, but i did everything the same as explained, but the tab doesnt become "selected" when its opened.

would be great if you add a sample of your test.php, because ive searched everywhere and didnt come accross with it

ragtek 11-30-2009 04:16 PM

Quote:

Originally Posted by ndL (Post 1921747)
please post "news.php" content, because i cant find how to make a selectednavtab, did what you have said, but it still doesnt work!

in news.php i have
PHP Code:

define(ragteknewstrue); 

what is very important but i think that it could be solves without
template:
PHP Code:

<template name="ragtek_news_navbar" templatetype="template" date="1258595041" username="ragtek" version="1.0.0">
- <![
CDATA[ <vb:if condition="$vboptions['selectednavtab'] == 'ragteknews'">
<
li class="selected">
    <
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><class="navtab" href="news.php{vb:raw session.sessionurl_q}">{vb:rawphrase ragtek_news}</a></li>
</
vb:if>
  ]]> 
  </
template

plugin at hook process_templates_complete
PHP Code:

if (defined('ragteknews'))
{
    
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render(); 


Adem GEN? 11-30-2009 08:30 PM

Quote:

Originally Posted by ragtek (Post 1923091)
in news.php i have
PHP Code:

define(ragteknewstrue); 


Thank you very much
Now okay


Regards

ndL 12-05-2009 06:33 PM

Thanks, this is what i needed.

define(ragteknews, true);

you must include this in your how-to

ragtek 12-05-2009 07:34 PM

i've updated the article

DesignWerks 12-11-2009 01:45 AM

Still tinkering around with this. Is it possible to define the selectednavtab for a CMS page to use with this method? For example if my news.php page was part of the CMS such as http://www.mydomain.com/content.php?5-news where would I define define(news, true); ?

Code:

<vb:if condition="$vboptions['selectednavtab'] == 'news'">
or is there a different condition I could use based on the "5-news" perhaps...

ragtek 12-11-2009 03:07 AM

Quote:

Originally Posted by DesignWerks (Post 1928639)
Still tinkering around with this. Is it possible to define the selectednavtab for a CMS page to use with this method? For example if my news.php page was part of the CMS such as http://www.mydomain.com/content.php?5-news where would I define define(news, true); ?

Code:

<vb:if condition="$vboptions['selectednavtab'] == 'news'">
or is there a different condition I could use based on the "5-news" perhaps...

atm i don't know this, sorry.

i wish this would be possible with vB4 ( http://www.vbulletin.com/forum/showt...07#post1852507 )^^

DesignWerks 12-11-2009 10:50 AM

Your template works like a charm for my non-CMS pages - thanks for that! I will have to leave News down in the submenu bar for now and hope that they improve the ability to manage the navbar in upcoming releases.

MaryTheG(r)eek 12-13-2009 09:14 AM

1 Attachment(s)
Fantastic! Thank you for sharing. It was the only missing to finish microSUPPORT for vB4. Works like a charm and I don't have wrong highlight problems.

Maria

ragtek 12-13-2009 10:51 AM

Quote:

Originally Posted by MicroHellas (Post 1929798)
Fantastic! Thank you for sharing. It was the only missing to finish microSUPPORT for vB4. Works like a charm and I don't have wrong highlight problems.

Maria

[ot]
haven't you wrote that you've finished with the vB Community and don't want to code anything else?[/ot]


All times are GMT. The time now is 08:47 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.01527 seconds
  • Memory Usage 1,857KB
  • 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
  • (7)bbcode_code_printable
  • (2)bbcode_html_printable
  • (6)bbcode_php_printable
  • (13)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
  • (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