Creating an Automatic News Archive - 2018 Version

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 2, 2018   (RSS)

By leo - April 24, 2018

Hi,

You can try replacing the where statement with the following and see if the error is still there:

'where' => "`createdDate` < '".date('Y-m-d H:i:s', strtotime('-1 year'))."'"

Let me know if this works!

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com

By jreddigital - May 2, 2018

Hi Leo, Glad to have you on board.

Your code worked, thank you.

For the record, here is what I did for an automatic archive news item page and the detail page - the code  below is for my LIST page.

// load records from 'notices_srpc'
list($notices_srpcRecords, $notices_srpcMetaData) = getRecords(array(
'tableName' => 'notices_srpc',
'loadUploads' => true,
'allowSearch' => false,
'ignoreRemoveDate' => true,
'where' => "`publishDate` < '".date('Y-m-d H:i:s', strtotime('-1 year'))."'"

));

Then, in order to be able to use the same Detail page as my current news listings, I used this code for the detail page. The key was to use the ignoreRemoveDate.  This is the active page  http://strafford.org/newsarchiveList.php

list($notices_srpcRecords, $notices_srpcMetaData) = getRecords(array(
'tableName' => 'notices_srpc',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
'ignoreRemoveDate' => true,
));
$notices_srpcRecord = @$notices_srpcRecords[0]; // get first record

macwebster