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)

MaryTheG(r)eek 12-13-2009 02:24 PM

Quote:

Originally Posted by ragtek (Post 1929823)
[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:)

nubian 12-17-2009 06:51 PM

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.

ragtek 12-17-2009 07:09 PM

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 :( )

Chee Foo 12-22-2009 05:32 AM

1 Attachment(s)
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();

oechertigger 12-22-2009 06:35 AM

@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

ragtek 12-22-2009 06:44 AM

You could also write "my phrase" instead of using a phrase;)

Chee Foo 12-23-2009 12:42 AM

Quote:

Originally Posted by oechertigger (Post 1935212)
@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 - ??

ragtek 12-23-2009 05:30 AM

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

Chee Foo 12-23-2009 02:23 PM

Thanks!! It works!

petermclane 12-29-2009 11:19 AM

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


All times are GMT. The time now is 04:41 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.01299 seconds
  • Memory Usage 1,762KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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