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

Quote:
Originally Posted by ragtek View Post
[ot]
haven't you wrote that you've finished with the vB Community and don't want to code anything else?[/ot]
Marketing tips my dear
Reply With Quote
  #43  
Old 12-17-2009, 06:51 PM
nubian nubian is offline
 
Join Date: Nov 2004
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I've been tinkering around with this tutorial and was close to raising the white flag of surrender because I could not understand this for the life of me.
So after long grueling hours, I've manage to figure things out and get things working...well sort of.

I've used Lynne's artcle "[HOW TO - vB4] Create a own vBulletin page" and managed to create an about us page.

My about us page named, "about.php" look like this...
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''aboutus_plug');
define('CSRF_PROTECTION'true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('about_us',);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits construct_navbits(array('' => 'About Us'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'My Page Title';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('aboutus_tmplt');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());
?>

My template page named, "aboutus_tmplt" looks like this...
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}
    
    <h2 class="blockhead">About Us blockhead text</h2>
    <div class="blockbody">
      <div class="blockrow">
       About Us text here
      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>
My plug-in script named, "aboutus_plug" looks like this...
PHP Code:
if (THIS_SCRIPT == 'aboutus_plug')
{
$tabselected ' class="selected"';
$vbulletin->options['selectednavtab'] = 'About Us';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="about.php">About Us</a>'.$tablinks.'</li>'
----------

It feels awesome when things just work!
Like they say, "If it ain't broken, don't fix it", well that's not how it is in my case because my knowledge of VB's coding is fairly basic so I feel like I may have butchered some things that weren't necessary.

What I'm concerned with is that I have no idea what this line of does in my plug-in code.
PHP Code:
$vbulletin->options['selectednavtab'] = 'About Us'
Because I could name it, "Foo" and it will still work.
Can anyone shed some light as what that line of code does?

Also what I'm hoping for is that if anyone can please verify that the lines of code I have posted are valid giving their respective names and all?
Any help will greatly be appreciated.

Thanks.
Reply With Quote
  #44  
Old 12-17-2009, 07:09 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1. because your template is called aboutus_tmplt you need
PHP Code:
$globaltemplates = array('aboutus_tmplt'); 
instead of
PHP Code:
$globaltemplates = array('about_us',); 
the other thing i don't understand. sorry(my english is horrible )
Reply With Quote
  #45  
Old 12-22-2009, 05:32 AM
Chee Foo Chee Foo is offline
 
Join Date: Sep 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I have added the template and plugin. But there is no letters appearing in the navbar.
Can anyone help ?

My template 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>

Plugin
if (THIS_SCRIPT == 'ragteknews')
{
//set selected tab
$vbulletin->options['selectednavtab'] = 'ragteknews';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_middle'] .= vB_Template::create('ragtek_news_navbar')->render();
Attached Images
File Type: jpg navbar.jpg (11.6 KB, 0 views)
Reply With Quote
  #46  
Old 12-22-2009, 06:35 AM
oechertigger oechertigger is offline
 
Join Date: Dec 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@Chee Foo

You have to define "ragtek_news" as a new Phrase in the AdminCP.
Then you will get the phrase you defined as the Tabname
Reply With Quote
  #47  
Old 12-22-2009, 06:44 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could also write "my phrase" instead of using a phrase
Reply With Quote
  #48  
Old 12-23-2009, 12:42 AM
Chee Foo Chee Foo is offline
 
Join Date: Sep 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oechertigger View Post
@Chee Foo

You have to define "ragtek_news" as a new Phrase in the AdminCP.
Then you will get the phrase you defined as the Tabname
What should I fill up in the fields under phrase manager ?
Phrase Type - Global ?
Product - vBulletin ?
Varname - ragtek_news ?
Text - ??
Reply With Quote
  #49  
Old 12-23-2009, 05:30 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Phrase Type: Global
Varname: A varname, which you will have to use in the template
Text: Yout text which will be shown in the template
Reply With Quote
  #50  
Old 12-23-2009, 02:23 PM
Chee Foo Chee Foo is offline
 
Join Date: Sep 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks!! It works!
Reply With Quote
  #51  
Old 12-29-2009, 11:19 AM
petermclane petermclane is offline
 
Join Date: Dec 2009
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works for me! Awesome, ty sir.

What about changing the order of the tabs... I see that in this example the tab is set to navtab_middle.
If I wanted to switch this tab (now in position 2 out of 3) with the default 'what's new' tab (now in position 3 out of 3)
would I state navtab_right ?

TYTY
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:11 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.04873 seconds
  • Memory Usage 2,362KB
  • 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
  • (1)bbcode_code
  • (2)bbcode_html
  • (6)bbcode_php
  • (2)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