Merge pull request #1143 from svandragt/3.1

ENHANCEMENT Sort menu items according to priority descending, then title ascending
This commit is contained in:
Ingo Schommer 2013-02-27 01:25:49 -08:00
commit 64b465f0cb
2 changed files with 12 additions and 6 deletions

View File

@ -150,15 +150,14 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider
}
}
// Sort menu items according to priority
// Sort menu items according to priority, then title asc
$menuPriority = array();
$i = 0;
$menuTitle = array();
foreach($menuItems as $key => $menuItem) {
$i++;
// This funny litle formula ensures that the first item added with the same priority will be left-most.
$menuPriority[$key] = $menuItem->priority*100 - $i;
$menuPriority[$key] = $menuItem->priority;
$menuTitle[$key] = $menuItem->title;
}
array_multisort($menuPriority, SORT_DESC, $menuItems);
array_multisort($menuPriority, SORT_DESC, $menuTitle, SORT_ASC, $menuItems);
return $menuItems;
}

View File

@ -54,6 +54,13 @@ abstract class ModelAdmin extends LeftAndMain {
* @var array|string
*/
public static $managed_models = null;
/**
* Override menu_priority so that ModelAdmin CMSMenu objects
* are grouped together directly above the Help menu item.
* @var float
*/
public static $menu_priority = -0.5;
public static $allowed_actions = array(
'ImportForm',