Jump to content

Return pages from, in-between and exclude specific year/years


Recommended Posts

Posted

I'm wanting to return pages of the current year only. I have a date field set up 'article_detail_date'; but unsure how to write this into the pages selector.

$pages->find("parent=articles, sort=article_detail_date");

I'm also curious to know whether you can do it between two years; and also exclude a specific year. My thinking would be...

$current_year = date('Y'); $article_year = article_detail_date('Y'); 
$pages->find("parent=articles, sort=article_detail_date, article_year=current_year");

Only thing is '$article_year' isn't working as it's before the loop...

Any ideas? Thanks!

Posted

There's no support for (mysql) date functions in the selector engine. You need to go this way:

$startOfYear = mktime(0,0,0,1,1,date('Y'));
$endOfYear = mktime(23,59,59,31,12,date('Y'));
$pages->find("…, article_detail_date>=$startOfYear, article_detail_date<=$endOfYear");
  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...