mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT Allowing to add pages from main interface, in addition to dialog triggered from admin/pages (through CMSPageAddController)
This commit is contained in:
parent
dccbb8b48a
commit
0d008b6496
@ -34,4 +34,5 @@ Object::add_extension('File', 'SiteTreeFileExtension');
|
|||||||
CMSMenu::remove_menu_item('CMSPageEditController');
|
CMSMenu::remove_menu_item('CMSPageEditController');
|
||||||
CMSMenu::remove_menu_item('CMSPageSettingsController');
|
CMSMenu::remove_menu_item('CMSPageSettingsController');
|
||||||
CMSMenu::remove_menu_item('CMSPageHistoryController');
|
CMSMenu::remove_menu_item('CMSPageHistoryController');
|
||||||
CMSMenu::remove_menu_item('CMSPageReportsController');
|
CMSMenu::remove_menu_item('CMSPageReportsController');
|
||||||
|
CMSMenu::remove_menu_item('CMSPageAddController');
|
@ -653,13 +653,16 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
|
|
||||||
|
$link = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID);
|
||||||
|
$this->getResponse()->addHeader('X-ControllerURL', $link);
|
||||||
|
|
||||||
if(isset($data['returnID'])) {
|
if(isset($data['returnID'])) {
|
||||||
return $record->ID;
|
return $record->ID;
|
||||||
} else if(Director::is_ajax()) {
|
} else if(Director::is_ajax()) {
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
return $form->forTemplate();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
return $this->redirect($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
code/controllers/CMSPageAddController.php
Normal file
27
code/controllers/CMSPageAddController.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
class CMSPageAddController extends CMSMain {
|
||||||
|
|
||||||
|
static $url_segment = 'page/add';
|
||||||
|
static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
static $url_priority = 42;
|
||||||
|
static $menu_title = 'Add page';
|
||||||
|
|
||||||
|
function AddForm() {
|
||||||
|
$form = parent::AddForm();
|
||||||
|
|
||||||
|
$form->addExtraClass('cms-content center cms-edit-form ' . $this->BaseCSSClasses());
|
||||||
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
if($parentID = $this->request->getVar('ParentID')) {
|
||||||
|
$form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doAdd($data, $form) {
|
||||||
|
$return = parent::doAdd($data, $form);
|
||||||
|
$this->getResponse()->addHeader('X-Controller', 'CMSPageEditController');
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
templates/Includes/CMSPageAddController_Content.ss
Normal file
37
templates/Includes/CMSPageAddController_Content.ss
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<% with AddForm %>
|
||||||
|
<form $FormAttributes data-layout="{type: 'border'}">
|
||||||
|
|
||||||
|
<div class="cms-content-header north">
|
||||||
|
<div>
|
||||||
|
<h2><% _t('CMSAddPageController.Title','Add pages') %></h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cms-content-fields center cms-panel-content cms-panel-padded">
|
||||||
|
|
||||||
|
<% if Message %>
|
||||||
|
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
||||||
|
<% else %>
|
||||||
|
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
|
||||||
|
<% end_if %>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<% if Legend %><legend>$Legend</legend><% end_if %>
|
||||||
|
<% control Fields %>
|
||||||
|
$FieldHolder
|
||||||
|
<% end_control %>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cms-content-actions south">
|
||||||
|
<% if Actions %>
|
||||||
|
<div class="Actions">
|
||||||
|
<% control Actions %>
|
||||||
|
$Field
|
||||||
|
<% end_control %>
|
||||||
|
</div>
|
||||||
|
<% end_if %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<% end_with %>
|
Loading…
Reference in New Issue
Block a user