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:
I have a feeling the filterByPublicDate part isn't right. The min date is ignored. Does anything scream "error"?
Thanks!
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!
http://www.weblicating.com/doku/doku.php?id=cheatsheet/#.VBk0lfl_uzM
I have been to that site many, many, many times. :)
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?
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?
You know what AndyJ? You totally nailed it! That was my issue. Good call! :)
Here's the final code:
THANKS!
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();
Viewing 15 lines of 16 lines. View entire code block.
THANKS!
Are you getting the $_REQUEST['years'] value correctly, please check it once.
I did make sure. :) Thanks for asking though!