modx getResources tv

318 views Asked by At

I have a page for a sports club based on ModXCMS 2.1.4. For a list of sport classes I have appr. 30 Documents for the different. Each of this has template variables like abteilung, Wochentag, Startzeit, etc. The tv.Wochentag contains Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag as weekdays.

Now my problem: The output is not sorted by the variable. Here my code:

[[getResources? 
&parents=`19`
&debug=`1` 
&tvFilters=`abteilung==[[*abteilung]]`
&sortby=`{tv.Wochentag:"Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag":"ASC",tv.UhrzeitStart:"ASC"}`
&tpl=`snipSportangebot` 
&includeTVs=`1` 
&tvPrefix=`` 
&limit=`0`
&processTVs=`1`]]

Finaly I would like to sort by Wochentag (Weekday) and StartZeit (Starttime/Time). What have I done wrong? Has anyone any hint on this.

Thanks in advance

Christian

2

There are 2 answers

2
mwl On

Join weekday and starttime to one TV - Input Type: Date, then you will be able to sorting by TV in getResources:

sortbyTV - Template Variable to sort by
sortdirTV - Order which to sort by when using sortbyTV
sortbyTVType - Specify the data type of the sortby TV. Possible values are string, integer, decimal, datetime

https://rtfm.modx.com/extras/revo/getresources

0
Sean Kimball On

Youy cannot sort by a TV using sortby [see the docs] if you try to use sortbyTV & sortdirTV it's going to sort them alphabetically for you.

set your day of the week tvs values to numeric :

Montag==0||Dienstag==1||Mittwoch==2||Donnerstag... etc

then your sortbyTV & sortdirTV should behave as expected