Content management system Silverstripe通过模型管理员添加页面不';t更新CMS

Content management system Silverstripe通过模型管理员添加页面不';t更新CMS,content-management-system,silverstripe,Content Management System,Silverstripe,我需要创建一个模型管理类,以便能够以模型管理样式创建页面。它曾经在2.4上工作,但自从LeftAndMain::ForceReload在3.1中被弃用后就不再工作了。简而言之,这里是我的CustomCalendarEvent类的一个片段: public function onBeforeWrite(){ parent::onBeforeWrite(); $parent_calendar_page = Calendar::get()->first(); $this->ParentID

我需要创建一个模型管理类,以便能够以模型管理样式创建页面。它曾经在2.4上工作,但自从LeftAndMain::ForceReload在3.1中被弃用后就不再工作了。简而言之,这里是我的CustomCalendarEvent类的一个片段:

public function onBeforeWrite(){
parent::onBeforeWrite();
$parent_calendar_page = Calendar::get()->first();
$this->ParentID = $parent_calendar_page->ID;
}

public function onAfterWrite(){
parent::onAfterWrite();
if(!$this->isPublished()){
$this->publish('Stage', 'Live');
$this->flushCache();
// This doesn't work anymore on SS 3.1
// LeftAndMain::ForceReload();
} 
}

你看过这篇文章的答案了吗?我读过这个问题,但是上面的代码是不同的,因为我只允许它发布一次。这就是检查DO/页面是否已发布的目的(如果(!$this->isPublished())。发布页面时我没有遇到任何问题,当您转到CMS的页面部分并从model admin查看新创建的页面时,问题更多地在于ajax调用。不确定我的解释是否有意义。为了让您了解我试图指出的内容,我留下了LeftAndMain::ForceReload()注释以说明我的目标。好的。我使用了drzax推荐的解决方案。不幸的是,同样的情况发生了,页面通过“保存/发布”按钮保存,但不会使用发布的新页面更新CMS的树管理部分。您仍然需要刷新浏览器以查看添加到树中的页面。