Jump to content

Date in selector issue


r2d2
 Share

Recommended Posts

Hi Everyone,

Any help is appreciated.

I'm trying to get either current and future events (pages) or past ones and am getting an error.

Here's my code ...

if ($page->showPastEvents) {
    $items = $pages->find("template=event, eventStartDate < today, limit=$page->numberOfItemsPerPage, sort=-date");
} else {
    $items = $pages->find("template=event, eventStartDate >= today, limit=$page->numberOfItemsPerPage, sort=-date");
}
 

I've also tried this:

$today = strtotime(date('Y-m-d'));
if ($page->showPastEvents) {
    $items = $pages->find("template=event, eventStartDate < $today, limit=$page->numberOfItemsPerPage, sort=-date");
} else {
    $items = $pages->find("template=event, eventStartDate >= $today, limit=$page->numberOfItemsPerPage, sort=-date");
}

And here's the error I'm getting, thoughts?

Error:     Exception: Unknown Selector operator: '' -- was your selector
value properly escaped? (in
/var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php
line 165)



#0
/var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php(190):
Selectors->create('eventStartDate', '', '>= 1374033600')

#1
/var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php(63):
Selectors->extractString('template=event,...')

#2 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Pages.php(143): Selectors->__construct('template=event,...')

#3 [internal function]: Pages->___find('template=event,...')

#4 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Wire.php(271): call_user_func_array(Array, Array)

#5 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Wire.php(229): Wire->runHooks('find', Array)

#6 /var/www/vhosts/sharespost.com/sharespost.co.v1/site/templates/basic-page-events.php(12): Wire->__call('find', Array)

#7 /var/www/vhosts/sharespost.com/sharespost.co.v1/site/templates

Link to comment
Share on other sites

Updated the "date" in sort. Here's the latest code but still not working. Thoughts?

$today = strtotime(date('Y-m-d'));
if ($page->showPastEvents) {
    $items = $pages->find("template=event, eventStartDate < $today, limit=$page->numberOfItemsPerPage, sort=-eventStartDate");
} else {
    $items = $pages->find("template=event, eventStartDate >= $today, limit=$page->numberOfItemsPerPage, sort=-eventStartDate");
}
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...