Silverstripe在cms编辑页面中重定向

问题描述 投票:2回答:1

我在silverstripe 3网站上设置了页面重定向。例如。当事件超过其日期时,页面将取消发布,用户将重定向到主事件页面。 - 这是在init函数中完成的

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/');
            }
        }
    }

但是,当我去编辑cms中未发布的页面时,页面仍然被重定向,因此我无法访问该页面进行编辑。

我想在以后更新事件页面并更改详细信息和到期日期,例如..当相同的事件在以后再次发生时,只需编辑然后重新发布旧页面而不是创建一个全新的页面。

有没有办法我可以设置它,以便页面将重定向在网站上,但不是在我尝试在cms中编辑它?

php redirect content-management-system silverstripe
1个回答
0
投票

通过修复代码解决。

$this->redirect('event-no-longer-available/');

不是必需的。替代这个可以在我的另一个问题Can I set a custom error page in silverstripe for certain page types?中看到,通过这样做,它停止了重定向。

© www.soinside.com 2019 - 2024. All rights reserved.