mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Section icons in CMS (#7269)
This commit is contained in:
parent
0d1e4cece5
commit
4029f96728
@ -437,9 +437,11 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* Returns the main menu of the CMS. This is also used by init()
|
||||
* to work out which sections the user has access to.
|
||||
*
|
||||
* @param Boolean
|
||||
* @return SS_List
|
||||
*/
|
||||
public function MainMenu() {
|
||||
public function MainMenu($cached = true) {
|
||||
if(!isset($this->_cache_MainMenu) || !$cached) {
|
||||
// Don't accidentally return a menu if you're not logged in - it's used to determine access.
|
||||
if(!Member::currentUser()) return new ArrayList();
|
||||
|
||||
@ -497,15 +499,25 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// if no current item is found, assume that first item is shown
|
||||
//if(!isset($foundCurrent))
|
||||
return $menu;
|
||||
$this->_cache_MainMenu = $menu;
|
||||
}
|
||||
|
||||
return $this->_cache_MainMenu;
|
||||
}
|
||||
|
||||
public function Menu() {
|
||||
return $this->renderWith($this->getTemplatesWithSuffix('_Menu'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Wrap in CMSMenu instance accessor
|
||||
* @return ArrayData A single menu entry (see {@link MainMenu})
|
||||
*/
|
||||
public function MenuCurrentItem() {
|
||||
$items = $this->MainMenu();
|
||||
return $items->find('LinkingMode', 'current');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of appropriate templates for this class, with the given suffix
|
||||
*/
|
||||
@ -1244,10 +1256,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
function SectionTitle() {
|
||||
if($title = $this->stat('menu_title')) return $title;
|
||||
|
||||
// Get menu - use obj() to cache it in the same place as the template engine
|
||||
$menu = $this->obj('MainMenu');
|
||||
|
||||
foreach($menu as $menuItem) {
|
||||
foreach($this->MainMenu() as $menuItem) {
|
||||
if($menuItem->LinkingMode != 'link') return $menuItem->Title;
|
||||
}
|
||||
}
|
||||
|
@ -262,6 +262,8 @@ body.cms { overflow: hidden; }
|
||||
.cms-content-header a { color: #1556b2; }
|
||||
.cms-content-header .backlink span.btn-icon-back { height: 16px; }
|
||||
.cms-content-header h2 { padding: 8px 8px 0 8px; font-size: 14px; line-height: 24px; font-weight: bold; text-shadow: #bfcad2 1px 1px 0; margin: 0; display: table-cell; vertical-align: top; width: 60%; }
|
||||
.cms-content-header h2 .section-icon { display: inline-block; vertical-align: middle; }
|
||||
.cms-content-header h2 .breadcrumbs-wrapper { display: inline-block; vertical-align: middle; }
|
||||
.cms-content-header h2 .breadcrumbs-wrapper .crumb { display: inline; line-height: 26px; padding: 0 5px; }
|
||||
.cms-content-header h2 .breadcrumbs-wrapper .crumb:first-child { padding-left: 0px; }
|
||||
.cms-content-header h2 .breadcrumbs-wrapper .crumb:last-child { padding-right: 0px; }
|
||||
|
@ -117,10 +117,16 @@ body.cms {
|
||||
display:table-cell;
|
||||
vertical-align:top;
|
||||
width:60%;
|
||||
|
||||
.section-icon {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.breadcrumbs-wrapper {
|
||||
// display:table;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
.crumb {
|
||||
// display:table-cell;
|
||||
display: inline;
|
||||
line-height:26px;
|
||||
padding:0 5px;
|
||||
|
7
admin/templates/Includes/CMSSectionIcon.ss
Normal file
7
admin/templates/Includes/CMSSectionIcon.ss
Normal file
@ -0,0 +1,7 @@
|
||||
<% if ToplevelController %>
|
||||
<span class="section-icon icon icon-16 icon-{$ToplevelController.MenuCurrentItem.Code.LowerCase}"></span>
|
||||
<% else_if Controller %>
|
||||
<span class="section-icon icon icon-16 icon-{$Controller.MenuCurrentItem.Code.LowerCase}"></span>
|
||||
<% else %>
|
||||
<span class="section-icon icon icon-16 icon-{$MenuCurrentItem.Code.LowerCase}"></span>
|
||||
<% end_if %>
|
@ -3,21 +3,11 @@
|
||||
<% end_if %>
|
||||
<div class="cms-content-header north">
|
||||
<div>
|
||||
<% with Controller %>
|
||||
<% if class=CMSFileAddController %>
|
||||
<span class="section-icon icon icon-24 icon-assetadmin"></span>
|
||||
<% else %>
|
||||
<% with ToplevelController %>
|
||||
<% if class=SecurityAdmin %>
|
||||
<span class="section-icon icon icon-24 icon-securityadmin"></span>
|
||||
<% end_if %>
|
||||
<% end_with %>
|
||||
<% end_if %>
|
||||
<% end_with %>
|
||||
<% include BackLink_Button %>
|
||||
|
||||
<h2 id="page-title-heading">
|
||||
<% control Controller %>
|
||||
<% include CMSSectionIcon %>
|
||||
<% include CMSBreadcrumbs %>
|
||||
<% end_control %>
|
||||
</h2>
|
||||
|
@ -3,6 +3,7 @@
|
||||
<div class="cms-content-header north">
|
||||
<div>
|
||||
<h2>
|
||||
<% include CMSSectionIcon %>
|
||||
<% if SectionTitle %>
|
||||
$SectionTitle
|
||||
<% else %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user