Log in

View Full Version : Fetching Multiple Templates


Adrian Schneider
10-30-2004, 11:51 PM
How do I fetch more than 1 template in a php file, I tried copying the line, but it didn't work. Here is the code for the page I am editing.
<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'league'); // 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(
'league',
);

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

);

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

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

$navbits = array();
$navbits[$parent] = 'SCD League';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// i want to fetch another template here
eval('print_output("' . fetch_template('league') . '");');
?>

miz
10-31-2004, 12:53 AM
How do I fetch more than 1 template in a php file, I tried copying the line, but it didn't work. Here is the code for the page I am editing.
<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'league'); // 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(
'league',
);

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

);

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

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

$navbits = array();
$navbits[$parent] = 'SCD League';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// i want to fetch another template here
eval('print_output("' . fetch_template('league') . '");');
?>


simply
add
eval('$varname= "' . fetch_template('templatename') . '";');

before

eval('print_output("' . fetch_template('league') . '");');

and edit template 'league' and add $varname where ever you want to show other template...

Adrian Schneider
10-31-2004, 02:35 AM
Thanks works great.

Zachery
10-31-2004, 02:05 AM
You need to make sure you cache the other templates

Adrian Schneider
10-31-2004, 03:20 PM
Hmm I didn't cache them and it worked, it is just for speed? Also, how would I make a template only show up to admins.

miz
10-31-2004, 03:39 PM
if ($bbuserinfo['usergroupid'] == "6") {
eval('$varname= "' . fetch_template('templatename') . '";');
}

this is a php condition , there is also a template condition
which i dont exsacly remember

Brad
10-31-2004, 04:29 PM
Hmm I didn't cache them and it worked, it is just for speed? Also, how would I make a template only show up to admins.
Yes, and server load...

If you don't cache the templates every call for a template requires anthor query to your database. By putting all the templates your going to use in the cache you can fetch them all with one query.