Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: Fix add new button not passing the correct parent ID.

The `%s` parent ID placeholder was being URL encoded, so it was not being
replaced properly when adding a new page. This fix separately adds
placeholder parameters to the URL to avoid this issue.

The fix is not ideal, but there is no easy way to indicate that some
URL parameters should be URL encoded and others should not while still
correctly constructing the URL.
  • Loading branch information...
commit b7476f2a46de1a856b56f0ca01d4a201066120ab 1 parent c3e25e9
@ajshort ajshort authored
View
12 code/controllers/CMSMain.php
@@ -202,10 +202,18 @@ public function LinkWithSearch($link) {
return $link;
}
- public function LinkPageAdd($extraArguments = null) {
+ public function LinkPageAdd($extra = null, $placeholders = null) {
$link = singleton("CMSPageAddController")->Link();
$this->extend('updateLinkPageAdd', $link);
- if($extraArguments) $link = Controller::join_links ($link, $extraArguments);
+
+ if($extra) {
+ $link = Controller::join_links ($link, $extra);
+ }
+
+ if($placeholders) {
+ $link .= (strpos($link, '?') === false ? "?$placeholders" : "&$placeholders");
+ }
+
return $link;
}
View
2  templates/Includes/CMSMain_TreeView.ss
@@ -19,7 +19,7 @@ $ExtraTreeTools
</div>
<% end_if %>
- <div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}" data-url-listview="{$Link('?view=list')}" data-hints="$SiteTreeHints.XML" data-extra-params="SecurityID=$SecurityID">
+ <div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1', 'ParentID=%s&amp;PageType=%s')}" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}" data-url-listview="{$Link('?view=list')}" data-hints="$SiteTreeHints.XML" data-extra-params="SecurityID=$SecurityID">
$SiteTreeAsUL
</div>
</div>
View
2  templates/Includes/CMSPagesController_ContentToolActions.ss
@@ -1,5 +1,5 @@
<div class="cms-actions-row">
- <a class="cms-page-add-button ss-ui-button ss-ui-action-constructive" data-icon="add" href="$LinkPageAdd" data-url-addpage="{$LinkPageAdd('?ParentID=%s')}"><% _t('CMSMain.AddNewButton', 'Add new') %></a>
+ <a class="cms-page-add-button ss-ui-button ss-ui-action-constructive" data-icon="add" href="$LinkPageAdd" data-url-addpage="{$LinkPageAdd('', 'ParentID=%s')}"><% _t('CMSMain.AddNewButton', 'Add new') %></a>
<button href="$LinkPagesWithSearch" class="cms-tree-expand-trigger cms-panel-link ss-button" data-icon="pencil">
<% _t('CMSMain.EditTree', 'Edit Tree') %>
</button>
Please sign in to comment.
Something went wrong with that request. Please try again.