[Flow] [Fluid] How can I use dynamic array indexes in templates?
Alexander Berl
a.berl at outlook.com
Wed Jun 12 13:20:47 CEST 2013
Hi Pavlina,
the (second) code with the viewhelper in it should work. If the array is
"rendered" in your template, that's most likely due to a syntax error.
Did you include the namespace "my" properly in your template/partial?
Other than that, also regard Bastians suggestion - most of the time
overly complex solutions can be prevented with a different approach.
PS: dynamic array access is already on the wish/todo list:
http://forge.typo3.org/issues/33215
Regards,
Alexander
Am 11.06.2013 21:29, schrieb Pavlina:
> Hi all!
>
> I am new in Typo3 Flow and I am currently developing my first project
> with it. I use Typo3 Flow 2.0 beta 1.
>
> I understood from this post:
>
> http://forge.typo3.org/projects/typo3v4-mvc/wiki/FAQ#How-can-I-use-dynamic-array-indexes
>
>
> that it's not possible to use dynamic array indexes in templates. But I
> need it very much. I have an array of arrays - items, grouped by week
> day - and I need to dynamically access each sub-array trough a weekDay
> variable and iterate it with the foreach view helper.
>
> I have found this code:
>
> https://gist.github.com/afoeder/2406841
>
> and I used it to write a custom view helper. My idea was to get each
> sub-array dynamically and pass it to the foreach view helper like this:
>
> <f:for each="<my:arrayAccess array={tasksGroupByWeekDay} key={weekDay}
> />" as="task">
>
> or
>
> <f:for each="{my:arrayAccess(array: tasksGroupByWeekDay, key: weekDay)}"
> as="task">
>
> But the custom view helper does not pass the array to the foreach view
> helper, it directly renders it in the template, which is obviously not
> what I heed. I couldn't find a way to write a view helper, which returns
> a value without render it in the template.
>
> Any help or suggestion which is the correct way to achieve my goal will
> be highly appreciated!
>
> Thank you in advance,
> Pavlina
More information about the Flow
mailing list