From b7476f2a46de1a856b56f0ca01d4a201066120ab Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Thu, 10 Oct 2013 13:09:24 +1100 Subject: [PATCH] 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. --- code/controllers/CMSMain.php | 12 ++++++++++-- templates/Includes/CMSMain_TreeView.ss | 2 +- .../CMSPagesController_ContentToolActions.ss | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 237464ff..4eb61963 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -202,10 +202,18 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 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; } diff --git a/templates/Includes/CMSMain_TreeView.ss b/templates/Includes/CMSMain_TreeView.ss index 2e9cb6b1..d8d8f39e 100644 --- a/templates/Includes/CMSMain_TreeView.ss +++ b/templates/Includes/CMSMain_TreeView.ss @@ -19,7 +19,7 @@ $ExtraTreeTools <% end_if %> -
+
$SiteTreeAsUL
diff --git a/templates/Includes/CMSPagesController_ContentToolActions.ss b/templates/Includes/CMSPagesController_ContentToolActions.ss index 5c44a42b..b3b8b6b4 100644 --- a/templates/Includes/CMSPagesController_ContentToolActions.ss +++ b/templates/Includes/CMSPagesController_ContentToolActions.ss @@ -1,5 +1,5 @@
- <% _t('CMSMain.AddNewButton', 'Add new') %> + <% _t('CMSMain.AddNewButton', 'Add new') %>