[Flow] [Fluid] How can I use dynamic array indexes in templates?

Pavlina pavlinadrosos at gmail.com
Thu Jun 13 21:39:25 CEST 2013


Hi all, 

thank you very much for your replies! The problem actually was a stupid syntactic error, I should have been really tired those evening...
I have published the code here:

https://gist.github.com/pdrosos/5776107

in case it could be useful to someone else in the future.

@Bastian Special thanks for your reply! Let me try to explain my purpose and why did I need this feature.

I am actually using objects. I have two model classes: Task and WeekPlan. 
The Task model has the following fields: name, date and description. 
The WeekPlan has these fields: name, start date, end date, mondaySchedule, tuesdaySchedule, wednesdaySchedule, thursdaySchedule, fridaySchedule. All schedule fields are simple text fields.

I must visualize the tasks and the week plans week by week. For each week day (Monday, Tuesday etc.) I must display the tasks, which belong to it and the week plans, which have a non-empty schedule field for it.
I get from the DB the tasks/week plans, which belong to the current week and group them by a week day in an array. The week day is the key of the array and the tasks/week plans for this day are the values. So I become array of objects, which I must iterate and display day by day.

I have a separate array with the week days and their calendar dates, because I need to display them all. I iterate over it and for each week day I must display the tasks/week plans, which belong to it. That's why I need a dynamic key access to the array with the tasks/week plans.

Another problem is how can I dynamically get the week plan daily schedule field by the week day. For example for Monday I should display the week plan's mondaySchedule field, for Tuesday - the tuesdaySchedule field and so on. I need a dynamic method name access to the week plan's getter methods.

I hope I have explained it clear enough. I will appreciate any suggestions how can I improve my implementation.

Thank you in advance!
Pavlina


More information about the Flow mailing list