silverstripe dopublish函数为ModelAdmin管理页面 [英] silverstripe dopublish function for ModelAdmin managed Pages
问题描述
在银幕后端我通过ModelAdmin管理某些PageTypes。到目前为止,工作正常,唯一的事情我不能弄清楚是如何使一个页面是发布保存时。
这是我的代码: p>
class ProjectPage extends Page {
public function onAfterWrite(){
$ this-> doPublish
parent :: onAfterWrite();
}
}
现在我仍然可以看到ModelAdmin创建的Sitetree中的页面,我可以看到它们处于草稿模式。如果我使用上面的代码,我得到这个错误:
在
... / framework / model / DataList.php中超过30秒的最大执行时间
许多thx,
Florian
得到超出最大执行时间的原因是因为 $ this-> doPublish();
调用 $ this-> write();
$ c> $ this-> onAfterWrite(); 。有你有无尽的循环。
这样做在 onAfterWrite()
或 write()
不工作
你应该只显示保存&发布按钮而不是保存按钮
但我想它的说起来容易做起来。
添加一个按钮实际上只是几行,但我们还需要一个提供按钮所说的功能。
这听起来像完美的呼吁创建一个新的模块,允许在模型管理中正确处理页面。我在SS2.4做了这个,我有一个很好的想法,如何做在SS3,但本周没有时间,在周末戳我在银河irc频道,也许我有时间在周末。 / p>
in the silverstripe backend I´m managing certain PageTypes via a ModelAdmin. That works fine so far, the only thing i can´t figure out is how to make a Page being "Published" when saving it.
Thats my code:
class ProjectPage extends Page {
public function onAfterWrite() {
$this->doPublish();
parent::onAfterWrite();
}
}
At the moment I can still see the ModelAdmin-created Pages in the Sitetree and I can see they are in Draft Mode. If I use the code above I get this error: Maximum execution time of 30 seconds exceeded in .../framework/model/DataList.php
Many thx, Florian
the reason why you get "Maximum execution time exceeded" is because $this->doPublish();
calls $this->write();
which then calls $this->onAfterWrite();
. And there you have your endless loop.
So doing this in onAfterWrite()
or write()
doesn't really work
you should just display the save & publish button instead of the save button But I guess its easier said than done. Well adding a button is actually just a few lines, but we also need a provide the functions that do what the button says it does.
This sounds like the perfect call for creating a new Module that allows proper handling of Pages in model admin. I have done this in SS2.4, and I have a pretty good idea of how to do it in SS3, but no time this week, poke me on the silverstripe irc channel on the weekend, maybe I have time on the weekend.
这篇关于silverstripe dopublish函数为ModelAdmin管理页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!