[TYPO3-mvc] Interresting problem with 'Duplicate variable declariations!'
Toke Herkild
th at t3cms.dk
Thu Nov 1 10:40:55 CET 2012
Den 01-11-2012 10:22, Toke Herkild skrev:
> Den 01-11-2012 10:11, Claus Due skrev:
>> Hi Toke,
>>
>> On Nov 1, 2012, at 10:03 AM, Toke Herkild <th at t3cms.dk> wrote:
>>
>>> <f:for each="models" as="model">
>>> <ul>
>>> <f:for each="{model.foo}" as="foo" >
>>> <li>{foo}</li>
>>> </f:for>
>>> </ul>
>>> </f:for>
>>
>> Is this your entire template? I assume no, since the above would not
>> work (models must be {models} or "expected array, got string" will
>> happen).
>>
>> If it is not your full template then there might be other things that
>> are not incuded here, such as the iteration argument. If you have used
>> the iteration argument and have used the same iteration variable name
>> in both loops, the error will happen ;)
>>
>> If your template must use the same variable names you will have better
>> luck by splitting your rendering up into multiple sections that you
>> don't pass {_all} arguments to but rather limit which arguments you
>> send along. Using sections/partials will clean the variable scope on
>> each rendering if you use them as described.
>>
>> PS: A nested foreach is completely valid.
>>
>> Cheers,
>> Claus
>>
>
> Hi Claus,
>
> I'll try to move this extended for loop into a section and see if it'll
> do a difference, tough I'm not sure, as I stated: in the first cycle
> everything works as expected, but the following cycles fail.
>
> Cheers,
> Toke
Hi Claus, and anyone else following this,
Listen to Claus when he says: "...splitting your rendering up into
multiple sections..."
Can't really see why, but it worked. Would like to know why it didn't
work before, but that'll have to wait till I'm not as busy as today.
Claus, Thanks for your help.
cheers,
Toke
More information about the TYPO3-project-typo3v4mvc
mailing list