[PHPTAL] Array Syntax Question
Werner
lists at mollentze.co.za
Fri Feb 16 16:59:39 CET 2007
Hi Laurent
Indeed I tried Joshua's solution (as you explained), but still cannot
get it to work. I think I am missing something simple here?
Here is a simple example of what I would like to do:
PHP:
$fooArr = array('item1', 'item2', 'item3');
$barArr = array('class1', 'class2', 'class3');
$fooArr holds the items i would like to iterate over.
$barArr holds the css classes that have to be assigned to each item.
Each item in $fooArr should be assigned the class of $barArr of the
corresponding array index.
Here follows the template source (that does not work):
PHPTAL:
<span tal:repeat="item fooArr" tal:omit-tag="">
<p tal:content="item" tal:attributes="class
barArr[repeat/item/index]">Some Foo Item</p>
</span>
Please provide an example of how to make this work using the "${...}"
syntax. Maybe I'm just too tired, but I cannot make it work.
Thanks for all your time and effort,
Werner
lbedubourg wrote:
> Werner wrote:
>> Hi again -
>>
>> Unfortunately none of your suggestions worked.
>
> Hi Werner,
>
> You did not try Joshua's solution, it is the right notation.
>
> When you write a tales path "foo/bar/baz", you abstract the type of
> each path component.
>
> I you want to make one part of the path dynamic, you have to use
> insert some ${foo} inside it :
>
> foo/${someKey}/baz
>
> Where 'foo' may be an array, an associative array, an object, ...
>
> Regards
> Laurent
>
More information about the PHPTAL
mailing list