diff --git a/code/CMSMain.php b/code/CMSMain.php index 192e433d..a05f2b4d 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -100,8 +100,16 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return true; } - function SwitchView() { - if($page = $this->currentPage()) { + /** + * Overloads the LeftAndMain::ShowView. Allows to pass a page as a parameter, so we are able + * to switch view also for archived versions. + */ + function SwitchView($page = null) { + if(!$page) { + $page = $this->currentPage(); + } + + if($page) { $nav = SilverStripeNavigator::get_for_record($page); Requirements::customScript("window.name = windowName('cms');"); return $nav['items']; @@ -924,7 +932,11 @@ JS; SSViewer::setOption('rewriteHashlinks', false); if($this->isAjax()) { - return $form->formHtmlContent(); + $content = $form->formHtmlContent(); + if($this->ShowSwitchView()) { + $content .= '
' . $this->SwitchView($record) . '
'; + } + return $content; } else { $templateData = $this->customise(array( "EditForm" => $form