3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 271 Views |
-
write() on Sitetree does not work

9 November 2011 at 11:17pm Last edited: 9 November 2011 11:19pm
Hello All,
i have a very simple counter function placed in Page_Controller in Page.php (which extends Sitetree):
public function ilike(){
$newCount = $this->Counter + 1;
$this->Counter = $newCount;
$this->write();
}somehow the data is never ever updated.
I also tried the update() function.
does not help. I get no errors or something.
are there any restrictions to write on a sitetree item?thanks in advance,
florian -
Re: write() on Sitetree does not work

10 November 2011 at 12:00am
Hi Florian,
the "write" is for a straight dataobject, but page is with versioned so you need to save and publish (or save to draft)... try somethign like...
$this->writeToStage('Stage');
$this->publish("Stage", "Live"); -
Re: write() on Sitetree does not work

10 November 2011 at 12:18am
hello swaiba! thank you,
but somehow that does not work as well.I saw kind of this solution in other posts but it never worked for me.
Maybe in the worst case I have to create an DataObject just holding the count and relate it to the Page.
cheers, Flo
-
Re: write() on Sitetree does not work

10 November 2011 at 4:52am
oh man
,
i moved now the function to the model class of Page.php.then it works:
public function countUp(){
$this->Counter = $this->Counter+1;
$this->writeToStage('Stage');
$this->publish("Stage", "Live");
}i can call this model function from the controller e.g. like this:
public function ilike(){
$this->countUp();
}
| 271 Views | ||
|
Page:
1
|
Go to Top |


