Reputation: 11
I have a list of records; all of them have a field .datetime (of type DateTime)
As step one, I want to have a loop for all records in ascending date order. Step two will be a "sort by pid", followed by a third step "sort by time".
But I can't get the VHS ViewHelper to work...
<f:for each="{recordlist -> v:iterator.sort(sortBy: '{f:format.date(date:recordlist.datetime, format:'Ymd')}')}" as="sortedrecord"> // iterating data which is ONLY sorted while rendering this particular loop {sortrecord.datetime}<br /> </f:for>
ends up in
#1256475113 InvalidArgumentException The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper".
Any idea how to make the iterator.sort work with a formatted date?
((Iterating directly over the dtaetime field will not work (iterator expects a string type variable), + cant get other inline format options to work.))
Upvotes: 1
Views: 182
Reputation: 1181
You will need to sort the array before formatting the date.
<f:for each="{recordlist -> v:iterator.sort(sortBy: 'datetime')}" as="record">
{record -> f:format.date(format: 'Ymd')}
</f:for>
It's not possible to sort formatted dates properly.
Upvotes: 0