how to get a reference to GLOBALS php variable inside template using Phptal

357 views Asked by At

Below line

tal:attributes="action php:GLOBALS['paypal']['url']"

raises:

PHPTAL_VariableNotFoundException' with message 'Unable to find variable 'GLOBALS' in current scope'

while

tal:attributes="action php:GLOBALS['paypal']['url']"

works

1

There are 1 answers

0
Kornel On

It's not a good practice to rely on globals at all. You should be passing variables to PHPTAL explicitly:

$phptal->set('paypal', $GLOBALS['paypal']);

and then use action="${paypal/url}"

or if you really must:

$phptal->set('GLOBALS', $GLOBALS);