Silverstripe 3 doPublish in Controller
-
13-12-2019 - |
문제
in an old silverstripe installation (2.4) i had a little counter function that looks basically like this:
class Page_Controller extends ContentController {
public function countUp(){
$this->Counter = $this->Counter+1;
$this->writeToStage('Stage');
$this->publish("Stage", "Live");
}
}
I want to move that over to SS 3. Somehow it does not work anymore, the Counter Property is never updated in the Datebase. Does someone know why?
Kind regards, Florian
해결책
1 - That method should be on the Page class (model), not the controller. You can then call $this->data()->countUp(); from the Page_Controller class.
2 - You need the line $this->write(); before $this->writeToStage('Stage');
제휴하지 않습니다 StackOverflow