Automatic news archive

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

By mizrahi - May 19, 2014

I would like to have the news area on a site automatically archive. I want everything within the past 12 months to display on a "Recent News" page, and everything older than 12 months to display on a "News Archive" page. Can someone assist me with the database calls for this? Here is the basic query...

// news items
  list($news_itemsRecords, $news_itemsMetaData) = getRecords(array(
    'tableName'   => 'news_items',
    'loadUploads' => true,
    'allowSearch' => false,
    'perPage'     => '20',
    'where'    => "(removeDate >= NOW() OR removeDate='0000-00-00 00:00:00')",
    'ignoreRemoveDate' =>  true,
  )); 

By mizrahi - May 19, 2014

Thanks.

FYI, the first getRecords worked fine, though it was missing a comma at the end of the where

The second getRecords didn't work, until I added back the "removeDate" fields, and the missing comma.