groupedFor - grouping objects according to dates

2019-08-12 08:58发布

The below code won't group my appointments according to the appointment-dates. The property date is a DateTime object (timestamp).

<f:groupedFor each="{appointments}" as="appointmentofdate" groupBy="date" groupKey="groupdate">

  {groupdate}:
  <br>
        <f:for each="{appointmentofdate}" as="appointment">

           {appointment.name} <br>
           {appointment.contact}

        </f:for>
        <hr>

</f:groupedFor>

Trying to format the date to the form "d.m" also didn't solve the issue:

<f:groupedFor each="{appointments}" as="appointmentofdate" groupBy="{f:format.date(date: date, format: 'd.m')}" groupKey="groupdate">

  {groupdate}:
  <br>
        <f:for each="{appointmentofdate}" as="appointment">

           {appointment.name} <br>
           {appointment.contact}

        </f:for>
        <hr>

</f:groupedFor>

How can i group all appointments according to their date?

I want the ouput:

02.09:
appointmentname1
Jerry Maier

appointmentname2
Esther Tannbaum

appointmentname3
Johnny Free
_____________________________________________
06.09:

appointmentname4
Otto Kringel

标签: php typo3 fluid
1条回答
混吃等死
2楼-- · 2019-08-12 09:10

You need an additional getter in your model. Rename the field

/**
 * Get day of datetime
 *
 * @return int
 */
public function getDayOfDatetime()
{
    return (int)$this->date->format('d');
}

This can be used then for grouping {appointments.dayOfDatetime}

查看更多
登录 后发表回答