I can not sort by TV with getresource


I have a couple of event and I print it from the newest to the oldest.
I use two TV: event_start, event_end and I defined the output as the following (US format)

GetResouce look like this

					&tplWrapper=`@INLINE [[+output]]` 

Note:; I also tried with &sortbyTV={"event_start":"ASC"}

You can see here, the order is not correct Nos événements - Société de développement d'Arzier-Le Muids
I think the problem should be aroud sortbyTVType or sortbyTV, isn’t?
Did I use the bad sort?


Try this instead:

1 Like

Yes!!! Thanks. This works

I have an additional question
How can I use a where close?

I would like to show only the future events include today date

where datetime >= today

I tried to add the following in my getResource without success

where={"datetime:>=" => [[!+nowdate:default=now:strtotime:date=%Y-%m-%d]]}

Note: datetime print 2024-01-18

Then all event prior today should not be shown

You can either use the &tvFilters property


or the &where property (for example) like this:

	&where=`["EXISTS (SELECT 1 FROM `modx_site_tmplvars` t INNER JOIN `modx_site_tmplvar_contentvalues` tc ON tc.tmplvarid = t.id WHERE CAST(tc.value AS DATETIME) >= CURDATE() AND t.name = 'event_start' AND tc.contentid = `modResource`.id)"]`

If you already use the TV “event_start” for the sorting (as shown in my previous post), then this might also work:

	&where=`["CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DATETIME) >= CURDATE()"]`
1 Like

Wonderful, thanks halftrainedharry