mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +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();
|
||||
}
|
||||
|
||||
|
||||
public function doAdd($data, $form) {
|
||||
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
||||
$parentMode = isset($data['ParentModeField']) ? $data['ParentModeField'] : "top";
|
||||
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
||||
|
||||
if ($parentMode == "top") $parentID = 0;
|
||||
|
||||
$suffix = isset($data['Suffix']) ? "-" . $data['Suffix'] : null;
|
||||
|
||||
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),
|
||||
// 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())),
|
||||
$parentField = new TreeDropdownField(
|
||||
"ParentID",
|
||||
sprintf($numericLabelTmpl, 1, _t('CMSMain.AddFormParentLabel', 'Choose parent')),
|
||||
'SiteTree'
|
||||
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",
|
||||
"",
|
||||
'SiteTree'
|
||||
)
|
||||
)
|
||||
),
|
||||
$typeField = new OptionsetField(
|
||||
"PageType",
|
||||
@ -1083,6 +1093,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
);
|
||||
$parentField->setShowSearch(true);
|
||||
|
||||
$parentModeField->setValue("child");
|
||||
|
||||
// CMSMain->currentPageID() automatically sets the homepage,
|
||||
// which we need to counteract in the default selection (which should default to root, ID=0)
|
||||
$homepageSegment = RootURLController::get_homepage_link();
|
||||
|
Loading…
Reference in New Issue
Block a user