21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 861 Views |
-
doPublish broken?

5 August 2010 at 9:41am
Hi All,
I have been having a lot of trouble using the doPublish, onBeforePublish and onAfterPublish methods on my Page classes. I just cannot seem to get the Silverstripe to call them when I click "save and publish".
I have seen that some other people have had issues with this, is this a bug? I cant really find any documentation around these methods, so does anyone know any links? Or at least a way I can debug the CMS to see why it is not using them?
Cheers,
Mo
-
Re: doPublish broken?

10 August 2010 at 4:31am
Had no one else had any problems with this?
My version of SIlverstripe is 2.4.1.
Cheers,
Mo
-
Re: doPublish broken?

10 August 2010 at 2:36pm
I use doPublish() , doUnPublish() etc in UserDefinedForms and it seems to work fine. The function has to be in the model and not the controller FYI and not in some dataobject (i.e has to be on the actual page type).
What code were you having trouble with?
-
Re: doPublish broken?

18 August 2010 at 10:03pm
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
| 861 Views | ||
|
Page:
1
|
Go to Top |


