MEM MEM - 2 months ago 57
Smarty Question

smarty code - access variables inside {php} tag

I know we should avoid the {php} tag inside any template engine, still, let's assume that it's the only way on this case.

Considering this, I would like to request some help in order to grab smarty string for php consumption.

On this case, I would like to access $result.domain inside the srtstr php function.

What am I doing wrong?

{foreach key=period item=regoption from=$result.regoptions}
{if $regoption.$domain}
{if $domain eq "transfer"}
$domainName = $result.domain;
$tld = strstr($domainName, '.');

{if $tld eq '.gt'}
<option value="{$period}">{$period} {$LANG.orderyears} @ {$regoption.$domain}</option>

Thanks in advance,

Answer Source

You can use get_template_vars, just make sure you use $this instead of $smarty


It would be a much better idea to rewrite what you are doing as a smarty plugin though


In your example you could do something like

$result = $this->get_template_vars('result');
$domainName = $result.domain;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download