paths in templates

From: Date: Thu, 13 Feb 2003 20:32:54 +0000
Subject: paths in templates
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7746@lists.php.net to get a copy of this message
I have a question about paths. I want to define all of my paths in an array and use these variables in my templates so that my php script can run in any location and the paths will all still work. To achieve this, I have a file, setup.php which contains the following: $root = $_SERVER['DOCUMENT_ROOT']; $SITE = array("images" => $root."/images/", "logos" => $root."/images/logos/", "javascripts" => $root."/javascripts/", "stylesheets" => $root."/stylesheets/", "sounds" => $root."/sounds/", ); class MySmarty extends Smarty { function MySmarty() { // Class Constructor. These automatically get set with each new instance. $this->Smarty(); $this->template_dir = '../templates/'; $this->compile_dir = '../templates_c/'; $this->config_dir = '../configs/'; $this->cache_dir = '../cache/'; $this->caching = true; $this->assign($SITE); } } In my template file, I want to use <img src="{$SITE.images}imagename.jpg"> I have a php script (mailer.php) which includes another php script (tabs.php). In this one, I have the following: $smarty = new MySmarty; $smarty->assign($SITE); $smarty->display("main_header.tpl"); $smarty->display("tabs2.tpl"); $smarty->display("main_footer.tpl"); mailer.php then has a bunch of html code as my template, and this is where I have the <img src="{$SITE.images}imagename.jpg"> Unfortunately, this variable does nothing in the template file, even though I have this at the top: <?php ini_set("include_path",".:./lib/"); include("tabs.php"); ?> I am not quite sure where I have gone wrong. Any advice is greatly appreciated! -Erich-

« previous php.smarty.general (#7746) next »