-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_item_weight_default.module
43 lines (39 loc) · 1.21 KB
/
menu_item_weight_default.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @file
* This module adds the ability do disable a nodes menu item from the node add/edit page
*/
/**
* Implements hook_help().
*/
function menu_item_weight_default_help($path, $arg) {
if ($path == 'admin/structure/menu/default-weight') {
return '<p>' . t('Use this configuration form to set default weights for node menu items from the node add/edit form') . '</p>';
}
}
/**
* Implements hook_menu().
*/
function menu_item_weight_default_menu() {
$items['admin/structure/menu/default-weight'] = array(
'title' => 'Menu Item Weight Default',
'page callback' => 'drupal_get_form',
'page arguments' => array('menu_item_weight_default_settings'),
'file' => 'menu_item_weight_default.admin.inc',
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 6,
);
return $items;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function menu_item_weight_default_form_node_form_alter(&$form, &$form_state, $form_id) {
$node = $form_state['node'];
$menu = $node->menu;
if ($menu['mlid'] == 0) {
// this is a new menu item
$form['menu']['link']['weight']['#default_value'] = variable_get('menu_item_weight_default', 0);
}
}