SV: Assign in prefilter
| From: | Andreas Heintze | Date: | Thu, 21 Mar 2002 23:17:53 +0000 |
| Subject: | SV: Assign in prefilter | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3264@lists.php.net to get a copy of this message | ||
Yes, but I needed the ability to assign in a prefilter so I got
This solution from Martin Søndergård Andersen [martin@inleadmedia.com]:
To get around this "problem" locate the "_compile_template" function in
Smarty.class.php, and replace the lines:
if ($smarty_compiler->_compile_file($tpl_file, $template_source,
$template_compiled))
return true;
with this:
if ($smarty_compiler->_compile_file($tpl_file, $template_source,
$template_compiled))
{
$this->_tpl_vars = array_merge($this->_tpl_vars,
$smarty_compiler->_tpl_vars);
return true;
}
This gives you the ability to assign vars in a prefilter.
But a cache should hold the output of the compiled template, but is the
cache php code too, which needs the $smarty->assign to be run?
Can you explain the difference of the 'compiled template' and the
'cached compiled template'?
Thanks!
Andreas
-----Ursprungligt meddelande-----
Från: Andrei Zmievski [mailto:andrei@ispi.net]
Skickat: den 22 mars 2002 00:01
Till: Andreas Heintze
Kopia: smarty@lists.ispi.net
Ämne: Re: [smarty] Assign in prefilter
On Thu, 21 Mar 2002, Andreas Heintze wrote:
> Found a problem when assigning vars in a prefilter.
> (using the modified version of Smarty.class.php)
>
> If using cache, when the cache expires or is cleared with
> $smarty->clear_all_cache(); and no recompile is done!
> The prefilter is not run and the assigned vars is missing in the
output!
>
> Can this be fixed somehow?
Prefilters are only run when the template is recompiled, that is by
design. It's not a bug.
-Andrei
Linux is like living in a teepee.
No Windows, no Gates, Apache in house.
- Usenet signature