mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT: added option to add page to top level
This commit is contained in:
parent
b0cb97a298
commit
463ee0c5f7
@ -620,10 +620,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return $form->forTemplate();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function doAdd($data, $form) {
|
public function doAdd($data, $form) {
|
||||||
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
||||||
|
$parentMode = isset($data['ParentModeField']) ? $data['ParentModeField'] : "top";
|
||||||
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
||||||
|
|
||||||
|
if ($parentMode == "top") $parentID = 0;
|
||||||
|
|
||||||
$suffix = isset($data['Suffix']) ? "-" . $data['Suffix'] : null;
|
$suffix = isset($data['Suffix']) ? "-" . $data['Suffix'] : null;
|
||||||
|
|
||||||
if(!$parentID && isset($data['Parent'])) {
|
if(!$parentID && isset($data['Parent'])) {
|
||||||
@ -1069,10 +1072,17 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
|
// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
|
||||||
// TODO Should be part of the form attribute, but not possible in current form API
|
// TODO Should be part of the form attribute, but not possible in current form API
|
||||||
$hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())),
|
$hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())),
|
||||||
$parentField = new TreeDropdownField(
|
new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))),
|
||||||
|
$parentModeField = new SelectionGroup(
|
||||||
|
"ParentModeField",
|
||||||
|
array(
|
||||||
|
"top//Top level" => null, //new LiteralField("Dummy", ''),
|
||||||
|
"child//Under another page" => $parentField = new TreeDropdownField(
|
||||||
"ParentID",
|
"ParentID",
|
||||||
sprintf($numericLabelTmpl, 1, _t('CMSMain.AddFormParentLabel', 'Choose parent')),
|
"",
|
||||||
'SiteTree'
|
'SiteTree'
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
$typeField = new OptionsetField(
|
$typeField = new OptionsetField(
|
||||||
"PageType",
|
"PageType",
|
||||||
@ -1083,6 +1093,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
);
|
);
|
||||||
$parentField->setShowSearch(true);
|
$parentField->setShowSearch(true);
|
||||||
|
|
||||||
|
$parentModeField->setValue("child");
|
||||||
|
|
||||||
// CMSMain->currentPageID() automatically sets the homepage,
|
// CMSMain->currentPageID() automatically sets the homepage,
|
||||||
// which we need to counteract in the default selection (which should default to root, ID=0)
|
// which we need to counteract in the default selection (which should default to root, ID=0)
|
||||||
$homepageSegment = RootURLController::get_homepage_link();
|
$homepageSegment = RootURLController::get_homepage_link();
|
||||||
|
Loading…
Reference in New Issue
Block a user