I am not quite sure about this, but reading from the smarty instructions http://www.smarty.net/docs/en/installing.smarty.basic.tpl , I would have to set $template_dir, $compile_dir, $config_dir, and $cache_dir every time I have a new PHP script. In other words, I would have to add the following lines of code for each PHP script:
$smarty->setTemplateDir('/.../templates/');
$smarty->setCompileDir('/...templates_c/');
$smarty->setConfigDir('/.../configs/');
$smarty->setCacheDir('/.../cache/');
Is that correct? Did you guys do any “shortcuts” to avoid this?
You should set all of these things in a common config file, then include it when you need it.
Then, in your common_config.php, you can just do something like this:
The use of “dirname( FILE )” will ensure that the path is always relative to the common config file.
Now all you need to do is use the display method with the name of the template file: