Re: different template paths
| From: | Monte Ohrt | Date: | Thu, 19 Jul 2001 15:39:30 +0000 |
| Subject: | Re: different template paths | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1213@lists.php.net to get a copy of this message | ||
An idea... how about supporting a search path in the $template_dir
variable:
$template_dir = "./templates:./template2:/some/other/dir";
or
$template_dir = array(
"r1" => "./templates:./template2:/default/dir",
"r2" => "./templates:./template3:/default/dir",
"r3" => "./templates:./template4:/default/dir"
)
This is a significant change though, because now the parser must check
for the existance of the template before displaying it, and check each
path sequentially. I'm not sure how this would affect other things. And,
would we want to support this in $config_dir and maybe other places?
Ralph Meijer wrote:
>
> On Thu, Jul 19, 2001 at 01:23:29PM +0200, Marc Logemann wrote:
> > Hi,
> >
> > i dont think that would help, the thing is, we need a search-path,
> > and this search path could be an array of several template path.
> >
> > Of course you can overide the actual template path, for different
> > scripts, but the include() problem still exists, because you cant
> > overide the template path within the parsing of a document.
> >
> > I like the idea of Monte below....
> >
>
> My problem maybe is of another kind: I have a site with functionality
> which can be represented in slightly different ways (layout and textual).
> The idea is that the script uses templates by the same name from different
> directories depending on via which affiliate partner a visitor is coming.
>
> Dir layout is like this:
>
> templates/$skin for overrides in layout and text
> templates/default for all basic functionality
>
> A template by the same name is first searched for in the first dir, and
> if not found in the second.
>
> (there are some more eleborate examples, but you get the idea)
>
> At this moment I use the template library of PHPLIB for this purpose with
> an altered file retrieval method.
>
> By looking at the code this could be achieved by having a method (initially
> no-op) which alters a relative template filename (functionality.tpl) to
> something which includes the extra information (e.g. $skin:functionality.tpl
> of something, the idea is that all dynamic information is in the resource
> before processing it further).
>
> After that you can use resource functions to do the actual searching.
> The last part can be done which the current functionality as long as your
> resources are static for all invocations. By adding a rewriting method
> you can simulate this.
>
> This method would be invoked at the beginning of _process_template as I
> now see it. Maybe I could do a test implementation this weekend.
>
> Another way of course is to write a template preprocessing function to alter
> all include directives to include the correct information, but that's a bit
> too much and I'd like to have the include directive as easy as possible.
>
> Any thoughts?
>
> Greetz,
>
> Ralphm
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/