SV: Re: prefilter?
| From: | Andreas Heintze | Date: | Fri, 15 Mar 2002 22:22:49 +0000 |
| Subject: | SV: Re: prefilter? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3094@lists.php.net to get a copy of this message | ||
I also needed the ability to assign vars in a prefilter and
I got a 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.
Please make this a Smarty standard.
/Andreas
-----Ursprungligt meddelande-----
Från: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net] För Monte Ohrt
Skickat: den 15 mars 2002 18:30
Till: smarty@lists.ispi.net
Kopia: smarty@lists.ispi.net
Ämne: [smarty] Re: prefilter?
I think there is currently a problem with assigning variables in
prefilters. Andrei will be looking at this, but he's not around until
next week.
Mark Leavy wrote:
>
> Hi,
> Is it possible to extract the smarty template vars from a
template, then
> assign values (rather than assign before hand)? E.g. in a template i
have
> {$module_userlogin} , i would like to be able to parse this template,
see
> $module_userlogin, load the file module_userlogin.php and assign the
return
> of new userlogin; (where userlogin is a class defined in
> module_userlogin.php). Basically so i can have some sort of dynamic
class
> loader.
> I'm sure this can be done (isn't this sort of how the plugins
work? sees a
> function and loads the plugin file with that function in it?), but i'm
having
> Friday afternoon brain melt down.
>
> Thanks
>
> MarkL
> mark@linux2002.org
>
> ---
> 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>
Director of Technology, ispi Inc.
---
You are currently subscribed to smarty as: andreas.heintze@home.se
To unsubscribe send a blank email to $subst('Email.Unsub')
Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/