Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Multiple config-file directories

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
rainco
Smarty Rookie


Joined: 13 Oct 2003
Posts: 31
Location: Germany

PostPosted: Sun Nov 16, 2003 12:58 pm    Post subject: Multiple config-file directories Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Nov 17, 2003 5:59 am    Post subject: Reply with quote

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
View user's profile Send private message
rainco
Smarty Rookie


Joined: 13 Oct 2003
Posts: 31
Location: Germany

PostPosted: Mon Nov 17, 2003 9:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Mon Nov 17, 2003 10:43 pm    Post subject: Reply with quote

Don't forget, this was a solution using a child class of Smarty.
Back to top
View user's profile Send private message
rainco
Smarty Rookie


Joined: 13 Oct 2003
Posts: 31
Location: Germany

PostPosted: Tue Nov 18, 2003 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 18, 2003 1:57 am    Post subject: Reply with quote

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
View user's profile Send private message
BloodRath
Smarty Rookie


Joined: 06 Jul 2003
Posts: 23
Location: France

PostPosted: Tue Nov 18, 2003 11:04 am    Post subject: CMs ant Template Reply with quote

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.... Wink
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP