Pregunta

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

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top