(redirected from Main.ConfiguringSmarty)
On this page... (hide)
So now you have Smarty installed and it's time to get it configured in you PHP application.
As we saw in Installing Smarty, adding Smarty to you application is as simple as including it somewhere in your code and instatiating a smarty object:
$smarty = new Smarty();
Setting Smarty environment
Smarty typically expects things to be in a standard place:
- templates is a subdirectory of your application's root
- templates_c is a subdirectory of your application's root and must be write-able by the server user/group.
If this is not the case, you can set where Smarty will find things explicitly:
$smarty->setCompileDir('/abs/path/to/your/application/templates_c/');
$smarty->setConfigDir('/abs/path/to/your/application/configs/');
$smarty->setCacheDir('/abs/path/to/your/application/cache/');
The above sets absolute paths to the directories Smarty wants to use. Again, make sure the web server user/group has permission to write to the templates_c and cache directories.
In practice, but putting templates and templates_c in the application root and chown-ing the latter to www-data:www-data seems sufficent without specifying paths directly.
<< back to Installing Smarty
On to Using Smarty >>
| Tags: | Categories: Articles |
Recent Changes |
Printable View |
Page History |
Edit Page
Page last modified on April 09, 2012, at 09:44 AM by tamara