RE: [SMARTY] Configuration

From: Date: Fri, 06 Oct 2006 17:31:25 +0000
Subject: RE: [SMARTY] Configuration
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13496@lists.php.net to get a copy of this message
> From: Urb LeJeune > I would like to accomplish the following: > > 1. Have Smarty always look in path > /home/e-gov/htdocs/templates for templates. > That works fine if I hard code the path in the display() function. > > 2. Have Smarty always look in the that > > /home/e-gov/htdocs/tempates_c or > /home/e-gov/htdocs/templates/templates_ > > Can this be done? I find it easiest to extend the Smarty class and set that stuff in the constructor, e.g. in php4: require_once 'Smarty.class.php'; class Template extends Smarty { function Template() { //Call Smarty Constructor $this->Smarty(); //Determine where the smarty files are -- slashes on both sides $base_path = _LOCALPATH.'/some/path/'; //Assign Smarty defaults -- trailing slash only $this->template_dir = _LOCALPATH.'/public_html/templates/'; $this->compile_dir = $base_path.'templates_c/'; $this->config_dir = $base_path.'configs/'; $this->cache_dir = $base_path.'cache/'; $this->plugins_dir = array(SMARTY_DIR.'/plugins', $base_path.'plugins/'); //cache settings, for when we do use caching $this->use_sub_dirs = 1; // enable cache subdirectories $this->cache_lifetime = 3600; // 60 minutes //caching turned off by default $this->caching = 0; } } Maybe there's a better way, but this works well for me. -- Max Schwanekamp NeptuneWebworks.com

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