PDA

View Full Version : Checking template variables..


stryka
02-11-2003, 11:25 AM
How do I check what template variables are being stored/called via functions.php.

Reason is... i have a custom template that calls $footer sucessfully but does not get any other custom template.

Thanx


<?php
error_reporting(7);
$templatesused='cust_header,footer,cust_notfound,c ust_main';


require(getenv('DOCUMENT_ROOT').'/global.php');
$var = $DB_site->query_first("SELECT * FROM etc ");

if($var)
{
eval("dooutput(\"".gettemplate('cust_main')."\");");
}
else
{
eval("dooutput(\"".gettemplate('cust_notfound')."\");");
}

?>


//cust_main is called successfully along with cust_notfound but cust_header & anything else called
in cust_main do not get displayed

Xenon
02-11-2003, 12:12 PM
$header and $footer are defined in global.php

so you have to define your variables before you can call em in templates..

stryka
02-11-2003, 12:27 PM
but i thought all template variables are defined in functions.php and that's why $cust_main is successfully called?

whats the diff with the other variable/template within $cust_main

i found // ###################### Start templates #######################

within global.php - should i add my custom template to the default list?actually , that didnt work...

trying to undestand how this thing works

Xenon
02-11-2003, 12:32 PM
nope, the part in functions.php just caches the content of templates, that you don't have to catch em from the db with every call.

you always have to define variables before you can use them.

example:


eval("\$cust_header = \"".gettemplate('cust_header')."\";");
eval("dooutput(\"".gettemplate('cust_main')."\");");

now you can use $cust_header in your cust_main template

stryka
02-11-2003, 12:40 PM
XENON THANK-YOU SO MUCH ...

I am obviously new to PHP and just trying to put things together... it took awhile to see how i call variables via non-vb pages and then i realized the power of custom templates... and this last answer you provided me know lets me do anything...

I definetly will come back in a couple weeks to collect all my custom template questions/answers for other newbies...

thanx again...

p.s. i think my next question will be... Where can i go to see how to add other templates to the cache? I have atleast two that will be called on every Non VB page...

Xenon
02-11-2003, 01:10 PM
:)
glad i could help :)

at PS: $templateused is the variable where you have to add templates to add em to the cache :)
in global.php it will affect every page ;)