3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Add an "All plans" link to the "Plans" menu.

This commit is contained in:
Michael Stenta 2017-11-16 11:36:29 -05:00
parent 8818b1aad5
commit a8f8e455dd
3 changed files with 16 additions and 8 deletions

View file

@ -29,10 +29,10 @@ function farm_ui_hook_info() {
*/
function farm_ui_menu_alter(&$items) {
// This function adds links to "All assets" and "All logs" in the Farm menu.
// In order to do that, we need to make sure that this hook runs after the
// Views module's implementation of hook_menu_alter(). That is accomplished
// via hook_module_implements_alter() below.
// This function adds links to "All assets", "All logs", and "All plans" in
// the Farm menu. In order to do that, we need to make sure that this hook
// runs after the Views module's implementation of hook_menu_alter(). That is
// accomplished via hook_module_implements_alter() below.
// Replicate the farm/assets menu item to farm/assets/all.
if (!empty($items['farm/assets'])) {
@ -44,9 +44,16 @@ function farm_ui_menu_alter(&$items) {
// Replicate the farm/logs menu item to farm/logs/all.
if (!empty($items['farm/logs'])) {
$items['farm/logs/all'] = $items['farm/logs'];
$items['farm/logs/all']['title'] = t('All Logs');
$items['farm/logs/all']['title'] = t('All logs');
$items['farm/logs/all']['weight'] = -100;
}
// Replicate the farm/plans menu item to farm/plans/all.
if (!empty($items['farm/plans'])) {
$items['farm/plans/all'] = $items['farm/plans'];
$items['farm/plans/all']['title'] = t('All plans');
$items['farm/plans/all']['weight'] = -100;
}
}
/**

View file

@ -3,7 +3,7 @@
attach: function(context, settings) {
if (settings.farm_theme.menu_dividers) {
var dividers = settings.farm_theme.menu_dividers;
var menus = ['assets', 'logs'];
var menus = ['assets', 'logs', 'plans'];
var weights = [0, 100];
for (var i = 0; i < menus.length; i++) {
for (var j = 0; j < weights.length; j++) {

View file

@ -44,13 +44,14 @@ function farm_theme_preprocess_menu_tree(&$variables) {
$menu = $variables['#tree'];
foreach (element_children($menu) as $child) {
// Define the
// Define the menu items we care about.
$menus = array(
'farm/assets' => 'assets',
'farm/logs' => 'logs',
'farm/plans' => 'plans',
);
// Only proceed for "Assets" and "Logs" menus.
// If we don't care about this menu item, skip it.
if (!array_key_exists($menu[$child]['#href'], $menus)) {
continue;
}