Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

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
  #32  
Old 11-30-2009, 04:10 PM
ndL ndL is offline
 
Join Date: Oct 2007
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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
Reply With Quote
  #33  
Old 11-30-2009, 04:16 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ndL View Post
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(); 
Reply With Quote
  #34  
Old 11-30-2009, 08:30 PM
Adem GEN?'s Avatar
Adem GEN? Adem GEN? is offline
 
Join Date: Apr 2005
Location: İstanbul / T?rkiye
Posts: 377
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
in news.php i have
PHP Code:
define(ragteknewstrue); 
Thank you very much
Now okay


Regards
Reply With Quote
  #35  
Old 12-05-2009, 06:33 PM
ndL ndL is offline
 
Join Date: Oct 2007
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, this is what i needed.

define(ragteknews, true);

you must include this in your how-to
Reply With Quote
  #36  
Old 12-05-2009, 07:34 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've updated the article
Reply With Quote
  #37  
Old 12-11-2009, 01:45 AM
DesignWerks DesignWerks is offline
 
Join Date: Apr 2009
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #38  
Old 12-11-2009, 03:07 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DesignWerks View Post
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 )^^
Reply With Quote
  #39  
Old 12-11-2009, 10:50 AM
DesignWerks DesignWerks is offline
 
Join Date: Apr 2009
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #40  
Old 12-13-2009, 09:14 AM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Attached Images
File Type: jpg microsupport_vb4.jpg (209.9 KB, 0 views)
Reply With Quote
  #41  
Old 12-13-2009, 10:51 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MicroHellas View Post
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]
Reply With Quote
Reply


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 04:06 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.05662 seconds
  • Memory Usage 2,358KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_html
  • (5)bbcode_php
  • (5)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
  • (4)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