BUG Fix inconsistent breadcrumbs in CMS section

Fixes #1867
This commit is contained in:
Damian Mooyman 2017-08-24 17:09:34 +12:00
parent 380de0eb17
commit 9350b4a425
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
4 changed files with 47 additions and 23 deletions

View File

@ -920,18 +920,54 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $this->getsubtree($this->getRequest());
}
/**
* Get "back" url for breadcrumbs
*
* @return string
*/
public function getBreadcrumbsBackLink()
{
$breadcrumbs = $this->Breadcrumbs();
if ($breadcrumbs->count() < 2) {
return $this->LinkPages();
}
// Get second from end breadcrumb
return $breadcrumbs
->offsetGet($breadcrumbs->count() - 2)
->Link;
}
/**
* @param bool $unlinked
* @return ArrayList
*/
public function Breadcrumbs($unlinked = false)
{
$items = parent::Breadcrumbs($unlinked);
$items = new ArrayList();
if ($items->count() > 1) {
// Specific to the SiteTree admin section, we never show the cms section and current
// page in the same breadcrumbs block.
$items->shift();
// Check if we are editing a page
/** @var SiteTree $record */
$record = $this->currentPage();
if (!$record) {
$items->push(new ArrayData(array(
'Title' => CMSPagesController::menu_title(),
'Link' => ($unlinked) ? false : $this->LinkPages()
)));
return $items;
}
// Add all ancestors
$ancestors = $record->getAncestors();
$ancestors = new ArrayList(array_reverse($ancestors->toArray()));
$ancestors->push($record);
/** @var SiteTree $ancestor */
foreach ($ancestors as $ancestor) {
$items->push(new ArrayData(array(
'Title' => $ancestor->getMenuTitle(),
'Link' => ($unlinked)
? false
: $ancestor->CMSEditLink()
)));
}
return $items;

View File

@ -418,13 +418,6 @@ class CMSPageHistoryController extends CMSMain
return $form;
}
public function Breadcrumbs($unlinked = false)
{
$crumbs = parent::Breadcrumbs($unlinked);
$crumbs[0]->Title = _t('SilverStripe\\CMS\\Controllers\\CMSPagesController.MENUTITLE', 'Pages');
return $crumbs;
}
/**
* Replace all data fields with HTML readonly fields to display diff
*

View File

@ -2,6 +2,8 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\View\ArrayData;
class CMSPageSettingsController extends CMSMain
{
@ -20,13 +22,6 @@ class CMSPageSettingsController extends CMSMain
return parent::getEditForm($id, ($record) ? $record->getSettingsFields() : null);
}
public function Breadcrumbs($unlinked = false)
{
$crumbs = parent::Breadcrumbs($unlinked);
$crumbs[0]->Title = _t('SilverStripe\\CMS\\Controllers\\CMSPagesController.MENUTITLE', 'Pages');
return $crumbs;
}
public function getTabIdentifier()
{
return 'settings';

View File

@ -5,24 +5,24 @@
<div class="fill-height flexbox-area-grow">
<div class="cms-content-header north">
<div class="cms-content-header-nav fill-width">
<a href="/admin/pages" class="btn btn-secondary btn--no-text font-icon-left-open-big hidden-lg-up toolbar__back-button"></a>
<a href="$BreadcrumbsBackLink" class="btn btn-secondary btn--no-text font-icon-left-open-big hidden-lg-up toolbar__back-button"></a>
<% include SilverStripe\\Admin\\CMSBreadcrumbs %>
<div class="cms-content-header-tabs cms-tabset">
<ul class="cms-tabset-nav-primary nav nav-tabs">
<li class="nav-item content-treeview<% if $TabIdentifier == 'edit' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageEdit" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageEdit">
<%t SilverStripe\CMS\Controllers\CMSMain.TabContent 'Content' %>
<%t SilverStripe\\CMS\\Controllers\\CMSMain.TabContent 'Content' %>
</a>
</li>
<li class="nav-item content-listview<% if $TabIdentifier == 'settings' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageSettings" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageSettings">
<%t SilverStripe\CMS\Controllers\CMSMain.TabSettings 'Settings' %>
<%t SilverStripe\\CMS\\Controllers\\CMSMain.TabSettings 'Settings' %>
</a>
</li>
<li class="nav-item content-listview<% if $TabIdentifier == 'history' %> ui-tabs-active<% end_if %>">
<a href="$LinkPageHistory" class="nav-link cms-panel-link" title="Form_EditForm" data-href="$LinkPageHistory">
<%t SilverStripe\CMS\Controllers\CMSMain.TabHistory 'History' %>
<%t SilverStripe\\CMS\\Controllers\\CMSMain.TabHistory 'History' %>
</a>
</li>
</ul>