vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   [SOLVED]Need help displaying variable data in vb4 custom template (https://vborg.vbsupport.ru/showthread.php?t=230449)

nirvana43 12-18-2009 04:34 AM

[SOLVED]Need help displaying variable data in vb4 custom template
 
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 :
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 :
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 :
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
Code:

$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


All times are GMT. The time now is 05:01 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.01030 seconds
  • Memory Usage 1,719KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete