[Flow] [Fluid] How can I use dynamic array indexes in templates?
Bastian Waidelich
bastian at typo3.org
Fri Jun 21 12:09:38 CEST 2013
Pavlina wrote:
Hi Pavlina,
let's give this a try:
> 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.
First of all:
I'm not sure whether I understood the meaning of "task" vs "week plan"
correctly, but couldn't you reduce this to one model from
Task
name: string
description: string
date: DateTime
WeekPlan
name: string
startDate: DateTime
endDate: DateTime
mondaySchedule: string
...
to:
Task
name: string
description: string
startDate: DateTime
endDate: DateTime
repetition: Enum (= e.g. an integer internally to support bitwise
options, see below)
If you need to render tasks differently you could add a "type" property.
> 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.
You should try to create those representations in your models, not in
the view.
For instance you could have a method in your repository that gets start
& end date and returns a collection of *Week* objects of which each has
a *getDays()* method that returns an array of *Day* objects that have a
getter for the *Task* objects.
This way, if you need a way to display (or count) all tasks of a week
directly you could simply add a getTasks() method to the Week object and
so on.
HTH
--
Bastian Waidelich
--
Core Developer Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the Flow
mailing list