2

I have a channel which is growing large through automatic daily imports. Is there any way to automatically remove (prune) entries older than X days? I've looked through the extension space without joy. It would certainly be possible to do this directly in the db but there are quite a few tables to deal with (sorry, that sounds whiny, eh?).

Anyway, I'd be glad for any thoughts or pointers. Thanks.

2
  • The frustrating thing is EE used to have a Data Pruning option that would have allow this - not automatically, but at least with a few clicks in the CP. Aug 20, 2013 at 12:13
  • Yes, I've seen references to that, but never used it. Those references made me ask here.... Aug 20, 2013 at 14:00

2 Answers 2

2

Yes there is! Andrew Weaver's Purgedata plugin will do exactly this.

From his website:

  • Delete content from selected weblogs that is older than a specified time
  • Ideal to accompany FeedGrab, CSVGrab and XMLGrab.

It works by adding the plugin's tag to an EE template and visiting the URL.

{exp:ajw_purgedata
  channel="9"
  days="2"
  hours="0"
}

This will delete all entries from channel with the id 9 which are more than 2 days old.

To run this automatically, you could try using a CRON job run wget as described here: https://stackoverflow.com/a/13259564/1013978

1

You can set "expiration date" to hide entries from displaying on front-end after certain date. And there could be an extension that will remove expired entries, if you worry about database growing too large. Though personally I would keep all entries, at least just for the record.

3
  • Thanks, Yuri. I actually want to remove from db, not just hide. And if such an extension exists now, I can't find it. Aug 5, 2013 at 16:02
  • Looks like it does not exist indeed. You can either include the code for entry deletion in the script responsible for entries import or create an extension. Api_channel_entries::delete_entry will do most of the work. Or email me, if you need a programmer :)
    – Yuri Salimovskiy
    Aug 5, 2013 at 16:14
  • Or, if you wanted to archive the entries in another database rather than delete them entirely, you could export them, THEN delete them. There are extensions to export data from one MySQL table to another - I've seen them. Look for extensions used to move EE installations, that allow you to selectively move channel contents.
    – user800
    Sep 4, 2013 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.