Re: [SMARTY] Re-compiling templates?
| From: | messju mohr | Date: | Tue, 11 Mar 2003 16:51:59 +0000 |
| Subject: | Re: [SMARTY] Re-compiling templates? | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8558@lists.php.net to get a copy of this message | ||
On Tue, Mar 11, 2003 at 04:03:07PM +0100, Sven Fuchs wrote:
> Hi Messju,
>
> >> for porting an existing application I need to have a mechanism
> >> to compile/parse the templates twice:
> >> - in a first round has to be assigned the biggest part of data,
> >> taking much time to access the database. After that the template
> >> has to be cached.
> >> - in a second round some minor changes have to be applied to the
> >> (cached or rebuild) template.
>
> > for the first round you enable caching.
> > for the second part you should use {insert} functions.
>
> Ah :) Hmm, as far I understand that insert.function mechanism, it's
> not applicable in this case. (Or am I wrong?)
>
> For example:
>
> <ul>
> {foreach from=$locations item=location}
> <li>{$location->getTitle()} [edit_link]
> {/foreach}
> </ul>
>
> [edit_link_definition]
> <a
> href="location_edit.php&locationId={$location->getID()}">edit</a>
> [/edit_link_definition]
>
> How do I get the edit_link parsed in at [edit_link] depending on some
> condition?
>
> If it was possible to get Smarty to really parse the template twice, I
> could do something like:
>
> <ul>
> {foreach from=$locations item=location}
> <li>{$location->getTitle()} {$location->getAdminName()}
> {literal}{if $session->isLoggedIn()}{/literal}
> <a href="...{$location->getID()}">edit</a>
> {literal}{/if}{/literal}
> {/foreach}
> </ul>
>
> I think, this would be straight forward, because I could use build-in
> functions like if/else, foreach, section etc. in the first and the
> second part.
hmm, this comes up every few weeks.
we are working on a solution, to make caching more flexible, so that
you can have passages in your template that are not cached, but
executed at display-time. but this is in an early stage, and cannot
say when this will work for testing, not to say for production.
for now, you could disable caching if $session->isLoggedIn()==true.
or you set the session_id as cache_id, then the pages are cached
for each individual user.
> Sven