Re: [PHPTAL] Duplcate/repeated macros
On 07.03.2010, at 15:44, Rowan @ Jetboy wrote: A very simple example. If I have a macro with a slot: div metal:define-macro=page div metal:define-slot=slot/div /div and another macro: div metal:define-macro=box div tal:content=heading/div /div I can fill 'slot' with multiple instances of 'box' like: div metal:use-macro=page div metal:fill-slot=slot div metal:use-macro=box/div div metal:use-macro=box/div /div /div As I'd expect, just using $template-heading = 'Heading name', echos 'Heading name' to both boxes. What do I need to change so I can insert unique heading content into each 'box' instance? You can locally redefine variables using tal:define, like this: div metal:fill-slot=slot div tal:define=heading string:another value metal:use-macro=box/ div metal:use-macro=box/ /div -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
[PHPTAL] Conditional slot containing element/s
If I have a containing 'wrapper' element to a slot definition: div class=wrapper tal:block metal:define-slot=content / /div how can I show or hide 'wrapper' dependent on whether the slot's filled? Slot filled: div class=wrapper pcontent/p /div Slot unfilled: Nothing! I appreciate I can move the slot definition to the 'wrapper' element, but this would mean having to insert 'wrapper', in addition to the content, whenever I wanted to use the slot. Presumably there's a better way? ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Conditional slot containing element/s
On 07.03.2010, at 18:42, Rowan @ Jetboy wrote: If I have a containing 'wrapper' element to a slot definition: div class=wrapper tal:block metal:define-slot=content / /div how can I show or hide 'wrapper' dependent on whether the slot's filled? Slot filled: div class=wrapper pcontent/p /div Slot unfilled: Nothing! I appreciate I can move the slot definition to the 'wrapper' element, but this would mean having to insert 'wrapper', in addition to the content, whenever I wanted to use the slot. Presumably there's a better way? I'm afraid that ability to check slot is not exposed in TALES. You could set a variable in addition to slot: div class=wrapper tal:omit-tag=true:hide-wrapper tal:block metal:define-slot=content / /div or if the wrapper is complex, create another macro that fills slot with the wrapper. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal