Closed zonky2 closed 1 year ago
Sorting an array can be done in the template relatively easy:
usort($this->arrData['boxes'], function($a, $b) {
return strnatcasecmp($a->text, $b->text);
});
And because the custom element does not have access to the element config this would be hard to do in the element itself.
das ist schon klar ;-) war die Frage, ob man das aus dem Template raus hält/halten möchte - das bearbeiten nach meiner Erfahrung auch durchaus ambitionierte Redakeure, die mit den "PHP-Zeugs" ggf. nichts anzufangen wissen
Eine Option zur Sortierung der Listenelemente wäre prima - könnte z.B. so aussehen:
mit
type
alssort
,natsort
undrandom
sowiedirection
alsasc
(Standard) oderdesc
- braucht man nicht beirandom
... bin aber noch nicht auf den Trichter gekommen, wo man das am Besten einbaut
m. E. wohl hier bei der Templateübergabe https://github.com/madeyourday/contao-rocksolid-custom-elements/blob/42c0b5c8e24895d763bda500e680566e7307f161/src/Element/CustomElement.php#L155-L159