For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2005 > Re: [SMARTY] Multiple Template Directories









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Multiple Template Directories
Vonleigh Simmons

2005-08-22, 9:58 pm

> You will find attached a file that I use on my web site. If the
> user has
> defined a template dir, it will be automaticaly used else the default
> templates are used.


Thank you Vincent for attaching the file, I appreciate the help.
I'm not sure this solution is going to work for me (at least how I
have it defined now). Reason is that the user might chose to override
the "header.tpl" file, but maybe not override the "footer.tpl". So
smarty would error out saying that it cannot find "footer.tpl" in the
user's template dir, as he hasn't provided one.

I could always make it mandatory that if you override one
template you must provide all (maybe copy them verbatim to his
template folder). But this seems a bit more of a hack, and I'd have
to build in a whole template management function.

I'd like it to work more like $PATH does in the shell. Basically
that it first searches the user template dir, and if that isn't found
the template it's looking for it goes to the main one. Kinda like /
usr/local/bin overrides /usr/bin by specifying it earlier in the path.


> require_once( 'smarty_api.php' );
> $smarty = new Smarty_custom();


Yep, I have smarty subclassed like that as per the manual.



Vonleigh Simmons
<http://illusionart.com/>
boots

2005-08-22, 9:58 pm

--- Vonleigh Simmons <nospam@illusionart.com> wrote: > > You will
find attached a file that I use on my web site. If the > > user
has > > defined a template dir, it will be automaticaly used else
the > default > > templates are used. > > Thank
you Vincent for attaching the file, I appreciate the help. >
> I'm not sure this solution is going to work for me (at least how
I > have it defined now). Reason is that the user might chose to
override > > the "header.tpl" file, but maybe not override
the "footer.tpl". So > smarty would error out saying that it
cannot find "footer.tpl" in the > > user's template dir, as
he hasn't provided one. > > I could always make it
mandatory that if you override one > template you must provide
all (maybe copy them verbatim to his > template folder). But this
seems a bit more of a hack, and I'd have > to build in a whole
template management function. > > I'd like it to work
more like $PATH does in the shell. Basically > > that it
first searches the user template dir, and if that isn't found >
> the template it's looking for it goes to the main one. Kinda
like / > usr/local/bin overrides /usr/bin by specifying it earlier
in the > path. 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. best regards. > >
require_once( 'smarty_api.php' ); > > $smarty = new
Smarty_custom(); > > Yep, I have smarty subclassed like
that as per the manual.



________________________________________
____________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com