M
M
Maxim Shadrin2019-02-12 09:58:02
MODX
Maxim Shadrin, 2019-02-12 09:58:02

How to sort with current date condition in collections modx table?

Hello. I have a rather banal problem that I can't solve.
There is a website that displays events.
There is an admin area where events are started, so that the manager is comfortable, I wrote the following plugin:

<?php
$e = & $modx->Event;
if ($e->name == 'OnDocFormSave') { 
//для меропреятий из Афиши
if ($resource->get('template') == 2) {
  $date = $resource->getTVValue('event_date');
  $resource->set('unpub_date', $date);
  $resource->save();
}

When saving an event, the date of the event is placed in the "date of unpublishing" field, i.e. the event is automatically removed from publication, in the collections table it automatically falls to the end, everyone is happy.
But, the customer asked to add the ability to watch past events on the site.
Which led to the fact that now they cannot be removed from publication, because otherwise they will not be visible to the average user on the site.
I had to disable this plugin.
And there was a problem. Now in the manager's admin area all events from the 1st created one are displayed.
The question is, is it possible to somehow set up the display of collections so that it uses today's date and compares it with the TV field with the date, in general, so that at first past events do not loom in the admin panel, but are somewhere at the end.
Maybe there is some kind of EVAL hack for the sort before field, where you can write a selection condition.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2019-02-12
@an-tar

Which led to the fact that now they cannot be removed from publication, because otherwise they will not be visible to the average user on the site.

And what prevents you from leaving everything as it was, however, in the event output snippet (which one do you use, by the way?), specify explicitly so that unpublished ones are also displayed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question