MEM MEM - 9 months ago 173
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"}
{php}
$domainName = $result.domain;
$tld = strstr($domainName, '.');
{/php}

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


Thanks in advance,
MEM

GWW GWW
Answer Source

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

$this->get_template_vars('foo')

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

EDIT:

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