Jump to content

Selector on page field with datetime subfield issue


Kiwi Chris
 Share

Recommended Posts

The selector in the following code included in a template is returning nothing, however if I take out the compId.resultsdate<={$today} bit, it works fine, although obviously not filtered on the date field.

$today = strtotime(date('Y-m-d'));
$setImages = $pages->find("template=competitionImage, compId={$page->id}, compId.resultsdate<={$today}, compSubject.name=s, imageRating.title=Merit|Honours,check_access=0");

Here's the results of an example from Tracey Debugger

templates_id=79, resultsdate<=1587729600, status<2048   SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_resultsdate AS field_resultsdate ON field_resultsdate.pages_id=pages.id AND (((field_resultsdate.data<='2020-04-25 00:00:00' ) )) WHERE (pages.templates_id=79) AND (pages.status<2048) GROUP BY pages.id

Over in my ready.php I have inside a hook that refers directly to the page template that's used for the pages in the page field above:

$today = strtotime(date('Y-m-d'))
$event->return = $event->pages->find("template=competition,eventEnd>={$today},eventStart<={$today}");

In this case the filtering on date fields (albeit different ones) works fine. Can anyone suggest why the filter on the date subfield of the page field isn't working?
Just to confirm, I do have a date value in the field, and it is a date before today. ?

The problem may be something blatantly obvious, but I can't for the life of me figure out why the selector is returning no results when I include the date filter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...