|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
martiendejong Smarty n00b
Joined: 17 Dec 2011 Posts: 2
|
Posted: Sat Dec 17, 2011 9:42 pm Post subject: Configurable Smarty work dir |
|
|
Hi all!
I must say I'm relatively new to Smarty since I just installed.
But I came across an issue that may be of interest to you guys as well.
When I was installing I noticed that Smarty has its workdir as '.' by default, and this is not configurable (without changing the code).
I would like to have my configuration setup in such a way that I use a separate folder out of my www folder for all Smarty related files.
So this is my structure:
var
..mysite
....www
......home.php
....app
......include
........smarty
..........Smarty.class.php
......smarty
........templates
........templates_c
........cache
My proposal is to add a constant called SMARTY_WORKDIR which is by default set to '.', and use it in the constructor instead of '.'.
This way people can set their Smarty work dir by overriding this variable.
TL;DR
When I was installing I noticed that Smarty has its workdir as '.' by default, and this is not configurable.
Solution: Add the constant SMARTY_WORKDIR:
in Smarty.class.php line 0:
Code: | if (!defined('SMARTY_WORKDIR')) {
define('SMARTY_WORKDIR', '.' . DS);
}
|
in Smarty.class.php line 595:
Code: | $this->setTemplateDir(SMARTY_WORKDIR . DS . 'templates' . DS)
->setCompileDir(SMARTY_WORKDIR . DS . 'templates_c' . DS)
->setPluginsDir(SMARTY_PLUGINS_DIR)
->setCacheDir(SMARTY_WORKDIR . DS . 'cache' . DS)
->setConfigDir(SMARTY_WORKDIR . DS . 'configs' . DS);
|
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Dec 17, 2011 11:37 pm Post subject: |
|
|
It's not necessary to modiy the code.
Just call
Code: | $smary->setTemplateDir(SMARTY_WORKDIR . DS . 'templates' . DS)
->setCompileDir(SMARTY_WORKDIR . DS . 'templates_c' . DS)
->setPluginsDir(SMARTY_PLUGINS_DIR)
->setCacheDir(SMARTY_WORKDIR . DS . 'cache' . DS)
->setConfigDir(SMARTY_WORKDIR . DS . 'configs' . DS); |
After you have created the $smarty object. |
|
Back to top |
|
martiendejong Smarty n00b
Joined: 17 Dec 2011 Posts: 2
|
Posted: Sun Dec 18, 2011 1:17 pm Post subject: |
|
|
Ok, that's a good solution too. Thanks for bringing that up! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|