Jump to content

Selector ">=" in PW2.3 doesn't work as in 2.2.x


Recommended Posts

I will post it here hoping that it is my mistake and it shouldn't be reported as PW issue. 

I have pages with field "event_datetime" with value similar to:

2013-02-09 19:00

2013-02-10 11:00

2013-02-12 19:00

2013-02-14 19:00

2013-02-15 19:00

2013-02-16 11:00

and code 

$today = "2013-02-11 21:34";
$rows = $events->find("event_datetime>=$today, limit=3");

in PW2.2.x 

echo count($rows) will output: 3

in PW2.3 

count($rows) is 0

Is it related to the new changes in the Selectors or I have to use another way to do it properly? 

Thanks in advance.
  • Like 1
Link to comment
Share on other sites

It sounds like a bug, so I want to find out some more details on how to reproduce. Specifically, what is the source of $events -- is it a Page or a PageArray? Can you provide the code the came before where $events was generated?

Also, do you see any difference if you change it to this?

$today = strtotime("2013-02-11 21:34"); 
$rows = $events->find("event_datetime>=$today, limit=3");  
Link to comment
Share on other sites

strtotime() helped and it is fine in PW2.3 too. Thanks, Ryan. 

In short: 

$today = date("Y-m-d H:i"); isnt working in PW 2.3

$today = strtotime(date("Y-m-d H:i")); is working in PW 2.3 as datetime selector

Anyway.. below is the code

All i was trying is to collect the next 3 events that are stored in repeater field in many pages. In other words..

January -> multiple events in one repeater field

Feb > multiple events in one repeater field. 


$eventsParent = $pages->get('template=events_parent');
$eventsPages = $eventsParent->children;

$events = new PageArray();
foreach ($eventsPages as $eventPage):

$today = date("Y-m-d H:i"); // good in PW2.2, not working as selector in PW2.3
// $today = strtotime(date("Y-m-d H:i")); // working as expected in PW 2.3
$rows = $events->find("event_datetime>=$today, limit=3");

Thanks again!

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

  • Create New...