Loading...
 
Features / Usability

Features / Usability


How to sort results (dates) from a dynamic tracker field in smarty

posts: 8633 Israel

I have trackeritems displayed in a plugin List using smarty template.

One of the field is a dynamic list field and it display a list of dates in unsorted order and that is very disturbing for users.

As there is no option in the DIL to display the results in a sorted order I wonder if we have a modifier or a function for this.

The results {$orderrow.holydaysDay} value is:

Copy to clipboard
holydaysDays => "17-10-2019<br>16-10-2019<br>15-10-2019"


From here I tried to sort in an inner foreach.
But couldn’t figure the right parameters or maybe this doesn’t exist in Tiki

Copy to clipboard
{foreach $orderrow.holydaysDays|sortby ??? as $date} {$date} {/foreach}



I also look for a javascript to split and sort the value... But it seem pretty prehistorical to go that way (but may be this is the only way ?)

posts: 126886 United Kingdom

Hi B

I think you'll need to use the PHP sort function https://www.php.net/sort

You'll need to add it as an allowed php function in the security control panel, and the use it something like (totally untested)

Hmm, but you'll need to turn the string into an array first... try

Copy to clipboard
{$dates = '<br>'|explode:$orderrow.holydaysDays} {$sort($dates)} {'<br>'|implode:$dates}


However... you will also have to change the date format so it sorts correctly, to YYYY-MM-DD - hmm, must be a better way eek


Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting