While it makes it much easier to include the Smarty Directory in your include path, you can't always do this if you are on a shared server. To get around this, Smarty allows you to specify the directories where its files are located.
When I create a Smarty based project, I always include the following lines in my configuration script:
PHP Code:
define (SMARTY_DIR, WEBPATH . '/includes/smarty/');
require(SMARTY_DIR.'Smarty.class.php');
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty = new Smarty;
$smarty->template_dir = WEBPATH . '/includes/smarty/cms/templates/';
$smarty->compile_dir = WEBPATH . '/includes/smarty/cms/templates_c/';
$smarty->config_dir = WEBPATH . '/includes/smarty/cms/configs/';
$smarty->cache_dir = WEBPATH . '/includes/smarty/cms/cache/';
This gives me more control over the entire layout of my project and where Smarty needs to work at.
You can also override Smarty's settings by using a class to extend it and set your variables within the constructor like the following:
PHP Code:
class pageDisplay extends Smarty {
function pageDisplay() {
$this->Smarty();
$this->template_dir = WEBPATH . '/includes/templates/templates/';
$this->compile_dir = WEBPATH . '/includes/templates/templates_c/';
$this->config_dir = WEBPATH . '/includes/templates/configs/';
$this->cache_dir = WEBPATH . '/includes/templates/cache/';
$this->caching = false;
$this->compile_check = false;
$this->debugging = false;
$this->assign('app_name','Metaquark CMS');
}
}
All of this is discussed in the Smarty manual that comes with the actual download. I haven't messed with the version included with PEAR at all though because of all the bad things I have heard about PEAR overall.
Bookmarks