I have a page redirect set up on my silverstripe 3 site. eg. When event has passed its date the page is unpublished and user redirected to main events page. - this is done in init function
public function init()
{
parent::init();
if ($this->ExpiryDate) {
$expiryDate = strtotime($this->ExpiryDate);
$currentDate = strtotime("now");
if ($expiryDate < $currentDate) {
$this->doUnpublish();
$this->redirect('event-no-longer-available/');
}
}
}
However, when I go to edit the unpublished pages in the cms the page is still redirected so I can't access the page to edit it.
I want to update the event page at a later date and change details and expiry date, for example.. when the same event happens again at a later date, just edit then republish the old page instead of creating a whole new page.
Is there a way I can set this up so that the page will redirect on the site but not while I'm trying to edit it in the cms??