문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top