logo       

Re: [SMARTY] Accessing Assigned Variables: msg#00469

php.smarty.general

Subject: Re: [SMARTY] Accessing Assigned Variables

On 31 Jan 2003 at 13:14, Darryl Bleau wrote:

>
> I think you misunderstand what I want to do.
>
> there is no '$var1' in my PHP. If you read closely, I assigned like this:
>
> $smarty->assign("var1","data");
>
> Just to make sure I wasn't on drugs, I tried what you said and of
> course, got back:
>
> Notice: Undefined variable: var1 in xxx.php on line xxx
>
> As I mentioned, I can do this by accessing $smarty->_tpl_vars['var1']
> but I thought there was a cleaner way.

I'm so stupid! Sorry, you're right - I totally misunderstood you.
Somehow I thought you wanted to know how to access smarty
variables from within templates - although the example was PHP-
code: if (...) instead of {if ...}.

Currently there is only one clean but circuitous way to access
assigned Smarty vars in PHP scripts:

$vars = $smarty->get_template_vars();
if ($vars['var1'] == 'data') {
// ...
}

Generally, one should avoid such situations by finishing all logic
before assigning smarty vars or even before creating the smarty
object.

Sorry for the inconvenience!!!

--
Ferdinand Beyer
<fbeyer@xxxxxxxxxxxx>


--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise