Expiring pages via page attribute

Permalink
Hi everyone,

I have found numerous posts discussing the automated deletion of expired pages through here but there seems to be so many, with so many different responses, so many different C5 versions and in my case, so many failed attempts that I am creating this hoping that someone might be able to share a solution that works for this specific request... I sincerely apologise if this has been clearly answered somewhere.

I have hundreds of pages being created by different contributors using the composer feature, I am successfully using quite a lot of custom attributes to make the editors life easier by basically being able to get all the custom features of their page handled within composer however the only thing I can't get to work is an expiration date.

I created a custom date attribute (called 'expiryDate') and am hoping it is possible that once the editor selects the expiration date, on that date the page is automatically deleted (via cron or Concrete5 jobs, I'm not sure). This is the point I'm getting lost.

I understand there is a feature similar if using the 'advanced permissions' feature but my goal is to have the clients contributors handle everything within their assigned composer page to limit errors.

If anyone can assist me with this, it would be greatly appreciated and I am open to payment if need be.

I am using Concrete5 version 5.6.1.2

 
juliandale replied on at Permalink Reply
juliandale
I'm not sure exactly how to do this, but I would start by copying the file at /concrete/core/jobs/remove_old_page_versions.php and pasting it to /jobs/remove_old_page_versions.php

From there, you may be able to extend the function of the job to do what you need, or at least use it as a basis to create your own custom job.
jshannon replied on at Permalink Reply
jshannon
Yeah. Julian has the right idea.

Only problem is that (if i recall correctly), jobs can't be installed from the dashboard. ie, they have to be installed as part of a package (or part of the core, but through code).

But once you get the job part down (not super complicated, but a specifically named class, etc), the code itself is pretty easy. A lot easier than something that needs to remove individual versions. From memory (so not 100% accurate), something like:

public function run() {
  $pl = new Pagelist();
  $pl->filterByexpiryDate(date('Y-m-d'), '<=');
  foreach ($pl->get() as $page) {
    $page->delete();
  }
}


Unfortunately, it sounds like you're looking for a ready-made solution. If I were you, I'd go through whatever you've found already and choose the simplest one and start there. Versions shouldn't make much of a difference... these are pretty stable features that you'd be using.
mobius2000 replied on at Permalink Reply
Hi jshannon and julliandale,

Thank you both for the reply... I'm now completely lost. I used the file from Jordanlav onhttp://www.concrete5.org/community/forums/usage/delete-pages-after-... but I can't seem to work out how to to bind it to my page attribute 'expiryDate'.

jshannon... In your reply, is the
$pl->filterByexpiryDate
the reference to the page attribute 'expiryDate' or is this something different?

Sorry guys, I'm not quite a newb but I'm pretty close to it :-)