End Date - hide/remove record

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 1, 2015   (RSS)

By Mikey - June 26, 2015

I'm need to create a solution to hide/remove records from displaying on a website page.

I've created a field called "End Date" (end_date) that is left empty by default, but a date can be entered for a specific date that the record should not be displayed on the website. Problem is - I can't seem to figure this out and make it work. I know there's the removeDate option, but that will not work for this section editor.

Here's the code I'm working from and a solution I tried that did not work marked as BOLD. Anyone have any suggestions to get this working?

// search results per page
if (@$_REQUEST['searchResultsPerPage'] AND is_numeric(@$_REQUEST['searchResultsPerPage'])){
  $perPage = $_REQUEST['searchResultsPerPage'];
}
else{
  $perPage = '8';
}
  
// load records from 'documents'
list($documentsRecords, $documentsMetaData) = getRecords(array(
'tableName'   => 'documents',
'perPage'     => @$perPage ? $perPage : '8',
'loadUploads' => true,
'allowSearch' => true,
'orderBy'     => 'date DESC',
'where'     => 'end_date <= NOW()',
));

Thanks,

Zick

By Dave - June 30, 2015

Hi Zick, 

Try this: 

'where'    =>   "(end_date <= NOW() OR end_date='0000-00-00 00:00:00')",

If that doesn't work, print out end_date and see what MySQL thinks it is.  Not all MySQL configurations let you store 0000-00-00 because it's not technically considered a valid date.  

Also note that you should be able to do everything you've mentioned with removedDate and neverRemove:
http://www.interactivetools.com/docs/cmsbuilder/special_fieldnames.html

Hope that helps!  Let me know any questions.

Dave Edis - Senior Developer
interactivetools.com

By Dave - June 30, 2015

Actually, no I think it is >= .  I'd try each part of the where individually and see which is limiting the results you want and print out the value of `end_date` to see what the unexpected records think the value is. 

Let me know what you find!

Dave Edis - Senior Developer
interactivetools.com

By Mikey - July 1, 2015

Thanks for the help Dave... got this working.