[TYPO3-mvc] sorting the values of a for-loop
Christian Essl
essl at incert.at
Wed Oct 5 10:37:00 CEST 2011
Hi,
I have a "kurstermin"-Model, which contains a start-date and an end-date, and the category it belongs to. Now I first sort the kurstermine by their category and then print out the dates with a for-loop:
<f:groupedFor each="{kurs.kursTermin}" as="kurstermineByCategory" groupBy=" category " groupKey=" category">
<td>
<f:for each="{kurstermineByCategory}" as="kurstermin" key="von">
<f:format.date format="d.m.y">{kurstermin.start}</f:format.date>
- <f:format.date format="d.m.y">{kurstermin.end}</f:format.date><br />
</f:for>
</td>
</f:groupedFor>
But by default the values are sorted by the uid. To sort the values by the start-date, I inserted the following inside my Repository:
class Tx_Extensionname_Domain_Repository_KursterminRepository extends Tx_Extbase_Persistence_Repository {
protected $defaultOrderings = array('start' => Tx_Extbase_Persistence_Query::ORDER_ASCENDING);
}
...but it doesn't seem to change anything. There are not custom methods in the Repository which could override the settings. So what is the best way to sort the output of a for-loop?
Regards,
Christian
More information about the TYPO3-project-typo3v4mvc
mailing list