Re: [SMARTY] Multiple Template Directories

From: Date: Tue, 23 Aug 2005 02:06:58 +0000
Subject: Re: [SMARTY] Multiple Template Directories
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12984@lists.php.net to get a copy of this message
--- Vonleigh Simmons <nospam@illusionart.com> wrote:&#10;> > You will find attached a file that I use on my web site. If the &#10;> > user has&#10;> > defined a template dir, it will be automaticaly used else the&#10;> default&#10;> > templates are used.&#10;> &#10;> Thank you Vincent for attaching the file, I appreciate the help.&#10;> &#10;> I'm not sure this solution is going to work for me (at least how I &#10;> have it defined now). Reason is that the user might chose to override&#10;> &#10;> the "header.tpl" file, but maybe not override the "footer.tpl". So &#10;> smarty would error out saying that it cannot find "footer.tpl" in the&#10;> &#10;> user's template dir, as he hasn't provided one.&#10;> &#10;> I could always make it mandatory that if you override one &#10;> template you must provide all (maybe copy them verbatim to his &#10;> template folder). But this seems a bit more of a hack, and I'd have &#10;> to build in a whole template management function.&#10;> &#10;> I'd like it to work more like $PATH does in the shell. Basically&#10;> &#10;> that it first searches the user template dir, and if that isn't found&#10;> &#10;> the template it's looking for it goes to the main one. Kinda like / &#10;> usr/local/bin overrides /usr/bin by specifying it earlier in the&#10;> path.&#10;&#10;&#10;I haven't been following entirely so if someone already mentioned this, my bad. At anyrate, this is essentially already possible, though unsupported. Simply assign template_dir using an array of paths (ie: instead of a single string, an array of strings) and Smarty will search each path in-order until it finds a matching template or fails. This way you get the basic override functionality you are describing. Again, AFAIK it is not officially supported but I have been using it for quite some time now and for exactly the reasons you give.&#10;&#10;best regards.&#10;&#10;&#10;> > require_once( 'smarty_api.php' );&#10;> > $smarty = new Smarty_custom();&#10;> &#10;> Yep, I have smarty subclassed like that as per the manual.&#10; ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs

« previous php.smarty.general (#12984) next »