RE: [SMARTY] Configuration

"Max Schwanekamp" <[email protected]> Fri, 6 Oct 2006 10:31:25 -0700
Newsgroups gmane.comp.php.smarty.general
Message-ID <00ff01c6e96d$41824000$650fa8c0@salamander>
> 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
 

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php