View previous topic :: View next topic |
Author |
Message |
rainco Smarty Rookie
Joined: 13 Oct 2003 Posts: 31 Location: Germany
|
Posted: Sun Nov 16, 2003 12:58 pm Post subject: Multiple config-file directories |
|
|
hi all!
i build an CMS using smarty. for the next version i plan to divide system- and project-files in a better way. for this my smarty related directory structure should look something like this:
/.../system/configs
/.../system/templates
/.../project/cache
/.../project/configs
/.../project/templates
/.../project/templates_c
to use to different template directories i implemented a simple resource plugin. so e.g. i can use $smarty->display("sys:useradmin.tpl") to access system templates an $smarty->display("file:page.tpl") to access project templates.
the problem is that i also have system- and project-configs and to keep them in different directories (as shown above). config-files will always be loaded from ONE config-dir. resources do not work here. so the only solution i see is to use "/" as config-dir and always give the full absolute path if i want to use a config-file. but this is very anoying. it would be nice if either there could be config-file resources or the possibility to use multiple config-file directories. or has anybody a different solution. i would be very glad if it is possible with a current smarty version.
thanks,
rainer |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Nov 17, 2003 5:59 am Post subject: |
|
|
I think I did a hack to config load or the config file class that used a resource to load config files. Hmmm. I could check, but I don't think it was generalized. At one point, there was discussion on the mailing list concerning this feature but I don't recall what ever became of it. Anyone? |
|
Back to top |
|
rainco Smarty Rookie
Joined: 13 Oct 2003 Posts: 31 Location: Germany
|
Posted: Mon Nov 17, 2003 9:50 am Post subject: |
|
|
I found a solution from Hinrich Donner at the mailinglist:
Code: |
function config_load($file, $section = null, $scope = 'global')
{
// If we do not have an array, we can proceed the normal method.
//
if (!isset($this->config_dirs) || !is_array($this->config_dirs))
return parent::config_load(&$file, &$section, &$scope);
// Now we have to move through the directories.
//
reset($this->config_dirs);
foreach ($this->config_dirs as $config_dir)
{
$this->config_dir = $config_dir;
parent::config_load(&$file, &$section, &$scope);
}
} |
messju posted that time, that it perhaps will be integrated after 2.5.0 release, but i think this was forgotton afterwards.
a solution integrated with smarty will be very nice, because i upgrade very often. Although Hinrichs solution is not very fine i think, because i want to decide from which config-dir a config-file should come in the template (in config_load). so resources would be much nicer!
has anybody found another solution? i would be very glad if something like this could be integrated in smarty 2.6.0-final or afterwards.
Could you post your hack too, boots?
thanks,
rainer |
|
Back to top |
|
Hinrich Smarty Rookie
Joined: 18 Apr 2003 Posts: 33
|
Posted: Mon Nov 17, 2003 10:43 pm Post subject: |
|
|
Don't forget, this was a solution using a child class of Smarty. |
|
Back to top |
|
rainco Smarty Rookie
Joined: 13 Oct 2003 Posts: 31 Location: Germany
|
Posted: Tue Nov 18, 2003 1:01 am Post subject: |
|
|
I implemented a solution using multiple config-file directories in a manner very much like template resources, without using a child class of smarty by patching function.config_load.php.
If you are interessted have a look at this:http://www.phpinsider.com/smarty-forum/viewtopic.php?p=6107#6107 |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Nov 18, 2003 1:57 am Post subject: |
|
|
The hack I refered to is perhaps not the best way to go about it as I did my work by overriding load_file() in the Config_File class--which means that other custom config classes would not get the benefit of the resource handling. On the other hand, it is perhaps logically a better place to implement than in config_load as config_load doesn't actually concern itself with file retreival details. IMHO the current config architecture has served its purpose well but it probably can stand a rethink.
My hack wasn't a general solution but was part of the proof-of-concept I did for templated config files. I'm not able to host the archive for long, so if you want to see it, it is available here. There is an old thread concerning this hack and also a more recent one.
Cheers! |
|
Back to top |
|
BloodRath Smarty Rookie
Joined: 06 Jul 2003 Posts: 23 Location: France
|
Posted: Tue Nov 18, 2003 11:04 am Post subject: CMs ant Template |
|
|
Sorry but i have done same kind of project as yours and to resolve problem of template dir distinct from global template smarty dir i use this trick :
use a global template in which i have a include to $frame_centrale
from my strart page xxx.php i set up some globals and
pass the smarty object started displayed to my module this one use a "private template dir " and include his private like this :
$page -> assign("frame_centrale","{$tplPath}rubrique_modify_select.tpl");
with $tplPath which is a full path to my "local template dir"
and i return the object smarty to my parent xxx.php to continue and at end display it
just about private dir, i achieve this kind of trick but just to set a private plugin dir, so i could conserve my plugin when changing version of smarty ? _________________ froggies forever.... |
|
Back to top |
|
|