You've blamed scoping on a few problems, so let me clarify how scoping works in
PHPTAL (it's quite simple actually :)
Variables set via $phptal->xxx or $phptal->set('xxx',...) are available
everywhere in the template.
Variables set in tal:define attribute live only as long as the element is open,
i.e.:
<div tal:define="x 'something'" tal:condition="x can be used here">
x works here
<div tal:define="something else">x works here too - scopes can be nested
without problems</div>
x works here
</div>
x is no more.
tal:define is evaluated before most other attributes, so you can use defined
variables in condition, repeat, etc.
You can redefine variables:
<div tal:define="x number:1">
${x} is 1
<div tal:define="x number:2"> ${x} is temporarily 2 now </div>
${x} is 1 again
</div>
Variables that are defined as global in the template behave more like PHP
variables and ignore nesting of tags:
global x isn't defined yet
<div tal:define="global x '...'">
x works here
</div>
and global x works here too
global variables can be permanently redefined by any tal:define.
local variables can "shadow" global variables:
<div tal:define="global x 'global'">
<div tal:define="x 'local'">
x is 'local'
</div>
x is 'global' again
</div>
but I suggest that you avoid global variables - it's easy to shoot yourself in the foot with them :)
When you need them, it might be sign that you're trying to put too much logic into the template.
--
regards, Kornel
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal