Hi WillR,
I have taken a lot of the code directly from the Userforms module. I have a HomePage class, with doPublish() on the model, then I have a dataobject with the Versioned extension added.
I think looking at it, my title for this thread may be incorrect. The Userforms module does work fine, but the doPublish() method just doesn't seem to get called on my page classes.
If its of any help, the code I am using is:
class HomePage extends Page {
...
public function doPublish() {
$live = Versioned::get_by_stage("QuadArea", "Live", "\"QuadArea\".\"ParentID\" = {$this->ID}");
if($live) {
foreach($live as $area) {
$area->doDeleteFromStage('Live');
}
}
$areas = Versioned::get_by_stage("QuadArea", "Stage", "\"QuadArea\".\"ParentID\" = {$this->ID}");
// publish the draft pages
if($areas) {
foreach($this->QuadAreas() as $area) {
$area->doPublish('Stage', 'Live');
}
}
parent::doPublish();
}
}
class QuadArea extends DataObject {
...
static $extensions = array(
"Versioned('Stage', 'Live')"
);
public function doPublish($fromStage, $toStage, $createNewVersion = false) {
$this->publish($fromStage, $toStage, $createNewVersion);
}
...
}
Any thoughts would be greatly appreciated.
Mo