Re: [SMARTY-DEV] How to modify the Smartytemplate loding policy
| From: | messju mohr | Date: | Tue, 25 Mar 2003 15:22:45 +0000 |
| Subject: | Re: [SMARTY-DEV] How to modify the Smartytemplate loding policy | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1022@lists.php.net to get a copy of this message | ||
On Tue, Mar 25, 2003 at 11:32:37AM -0300, luis wrote:
> Messju,
> I was looking for a "neat" way to do what I needed, that after all, is
> not that weird. That's why I didn't dive into the code :-)
> Do you think that an extra if statement can be a serious performance
> problem in _smarty_include?
i thought of traversing a search-path for the template. you have to
do a stat() call (aka file_exists()) for each segment in your path,
until the template in question is found. you have to do this for every
template that is included. i think this can become a
performance-problem. i think this may even be the reason, why smarty
does not support multiple template directories natively.
but give it a try and if it get's your job done it good. one (in this
case me) shouldn't try to optimize in the design-phase anyway :)
> Luis
>
> -----Original Message-----
> From: messju mohr [mailto:messju@lammfellpuschen.de]
> Sent: Tuesday, March 25, 2003 11:06 AM
> To: luis
> Cc: 'Smarty-Dev'
> Subject: Re: [SMARTY-DEV] How to modify the Smartytemplate loding policy
>
> On Tue, Mar 25, 2003 at 10:44:55AM -0300, luis wrote:
> > Why would I change {include} ? The application will then be hard to
> > maintain because it's logical to use {include} to do {includes} In
> some
> > point {include} must share some code with {fetch} to get a template
> from
> > the source. I just want to know where is that intersecting code to
> > change it and load templates from one dir or another.
>
> look in the compiled template what is generated when you have
> {include} in your template. you'll see that $this->_smarty_include()
> is called.
>
> both, fetch() and _smarty_include() use _get_compile_path() to retrieve
> the path to the template. this is the intersecting part of them.
> (you could have figured this out easily, if you had a look at the
> source)
>
> but you won't be happy in overruling _get_compile_path() to search a
> path of template-directories, since _get_compile_path() is also used
> to retrieve the compile-path of a template to *write* after compiling.
> this can have funny effects.
>
> you should better override _smarty_include() instead. but i'm sure it
> will be a significant performance-hit to your compiled templates (if
> no caching is in use).
>
> > -----Original Message-----
> > From: Jimmy Harlindong [mailto:jimmy@harlindong.com]
> > Sent: Tuesday, March 25, 2003 10:13 AM
> > To: Smarty-Dev
> > Subject: Re: [SMARTY-DEV] How to modify the Smartytemplate loding
> policy
> >
> > How about using a custom function?
> >
> > {insert}
> >
> > or define a custom tag.
> >
> > ----- Original Message -----
> > From: "luis" <luis@fuegolabs.com>
> > To: "'luis'" <luis@fuegolabs.com>; "'Jason
> > Sweat'"
> > <sweatjejm@mchsi.com>; <aztek@box.sk>
> > Cc: "'Smarty Dev'" <smarty-dev@lists.php.net>
> > Sent: Tuesday, March 25, 2003 10:19 PM
> > Subject: [SMARTY-DEV] How to modify the Smartytemplate loding policy
> >
> >
> > > Well, I can answer myself, no.
> > > If I have
> > > display('foo.tpl');
> > > and foo.tpl {includes file='header.tpl'}
> > > I need to look BOTH for foo.tpl and header.tpl in templates/$user
> and
> > if
> > > they are not found there in templates/
> > > If I redefine fetch then foo.tpl can be checked but fetch is not
> > called
> > > for the included header.tpl template.
> > > Ideas?
> >
> >
> >
> > --
> > Smarty Development Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > Smarty Development Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> E-Commerce: Verkauft etwas, das mit elektrischem Strom funktioniert.
> (modern
> für Multimedia)
> Andreas
> Krennmair
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
E-Commerce: Verkauft etwas, das mit elektrischem Strom funktioniert. (modern
für Multimedia)
Andreas Krennmair