PDA

View Full Version : [SOLVED]Need help displaying variable data in vb4 custom template


nirvana43
12-18-2009, 04:34 AM
I'm trying to create a custom template for vb4.
Following is the situation :

On my forum root, i have aa.php (Located at ../my_forum_root/aa.php) which includes bb.php located under ../my_forum_root/bb/bb.php

bb.php contains following code :
<?php
$test="test 123";
?>

I have created a template under main style and trying to print data under $test variable.

aa.php contains following code :

<?php
include('bb/bb.php');
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

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

define('THIS_SCRIPT', 'aa');
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('aa',
);

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

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

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

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

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'test 123';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('aa');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

?>


Template "aa" under main style contains following 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">TEST ABC</h2>
<div class="blockbody">
<div class="blockrow">
{vb:raw contents}
</div>
</div>

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

However above code aint working for me.
Am i missing something??
I would like to know how do i render data under some variable in vb4 templates. :)

BBR-APBT
12-18-2009, 04:36 AM
add

$templater->register('test', $test);


You have to register all variables you would like to use.

nirvana43
12-18-2009, 09:54 AM
Thanks BBR-APBT for your time.
I got it sorted out. I forgot to register variables for my custom made template. lolz :p