filterByPublicDate function

Permalink
Hey guys!

I'm going bonkers and I know it's something that's simple. I'm trying to get a page list for a year and it's not working. I've got it working in the past. I just know I'm not seeing something simple. Here's what I got:

$year = htmlentities($_REQUEST['years']); //gets the select value.
      $max_date = date('Y-m-d', strtotime($year.'-12-31'));
      $min_date = date('Y-m-d', strtotime($year.'-1-1'));
      //Entire years worth
?>
   <h4><?php echo $yrs;?> News Articles</h4>
   <?php
      Loader::model('page_list');
      $pl = new PageList();
      $pl->filterByPath('/news'); 
      $pl->filterByAttribute('exclude_page_list', 0, '='); 
      $pl->filterByPublicDate($max_date, '<=');
      $pl->filterByPublicDate($min_date, '>=');
      $pages = $pl->getPage();


I have a feeling the filterByPublicDate part isn't right. The min date is ignored. Does anything scream "error"?

Thanks!

rainmaker
 
zuna replied on at Permalink Reply
http://www.weblicating.com/doku/doku.php?id=cheatsheet/#.VBk0lfl_uzM
rainmaker replied on at Permalink Reply
rainmaker
I have been to that site many, many, many times. :)
WebcentricLtd replied on at Permalink Best Answer Reply
hello,
just off the top of my head - does it make any difference if you specify your min date:

$min_date = date('Y-m-d', strtotime($year.'-01-01'));
or
$min_date = date('Y-m-j', strtotime($year.'-1-1'));

instead of how you have it now?
rainmaker replied on at Permalink Reply
rainmaker
You know what AndyJ? You totally nailed it! That was my issue. Good call! :)

Here's the final code:
<?php 
$year = htmlentities($_REQUEST['year']);
      $max_date = date('Y-m-d', strtotime($year.'-12-31'));
      $min_date = date('Y-m-d', strtotime($year.'-01-01'));
      //Entire years worth
?>
   <h4><?php echo $year;?> News Articles</h4>
   <?php
      Loader::model('page_list');
      $pl = new PageList();
      $pl->filterByPath('/news'); 
      $pl->filterByAttribute('exclude_page_list', 0, '='); 
      $pl->filterByPublicDate($max_date, '<=');
      $pl->filterByPublicDate($min_date, '>=');
      $pages = $pl->getPage();


THANKS!
theneptune replied on at Permalink Reply
theneptune
Are you getting the $_REQUEST['years'] value correctly, please check it once.
rainmaker replied on at Permalink Reply
rainmaker
I did make sure. :) Thanks for asking though!