21311 Posts in 5739 Topics by 2604 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 234 Views |
-
Create children on Populate defaults

8 April 2012 at 9:40pm
how to create pages and at the same time creating her children?
I try using populate defaults
public function populateDefaults(){
parent::populateDefaults();$p = new Page();
$p->Title = 'TitlePage';
$p->MenuTitle = 'MenuTitle';
$p->URLSegment = $p->Title;
$p->Content = '';
$p->Status = 'Published';
$p->write();
$p->doRestoreToStage();
$p->publish('Stage', 'Live');
$p->flushCache();
}Any idea to create this structure?
-
Re: Create children on Populate defaults

8 April 2012 at 11:39pm
A child is set by populating the ParentID with the ID of the parent
$parent = new Page();
$parent->Title = 'TitlePage';
$parent->MenuTitle = 'MenuTitle';
$parent->URLSegment = $parent->Title;
$parent->write();
$parent->publish('Stage', 'Live');$child = new Page();
$child->Title = 'Child TitlePage';
$child->ParentID = $parent->ID;
$child->MenuTitle = 'Child MenuTitle';
$child->URLSegment = $child->Title;
$child->write();
$child->publish('Stage', 'Live'); -
Re: Create children on Populate defaults

9 April 2012 at 4:45am
i try but didn't work...
When create the page in CMS no child is created
-
Re: Create children on Populate defaults

9 April 2012 at 5:04am
using this code and work fine
public function populateDefaults(){
parent::populateDefaults();$this->write();
$this->publish('Stage', 'Stage');$child = new Page();
$child->Title = 'Child TitlePage';
$child->ParentID = $this->ID;
$child->MenuTitle = 'Child MenuTitle';
$child->URLSegment = $child->Title;
$child->write();
$child->publish('Stage', 'Stage');
}
| 234 Views | ||
|
Page:
1
|
Go to Top |


