You are here

function menu_link_weight_form_menu_overview_form_alter in Menu Link Weight 7

Implements hook_form_FORM_ID_alter() for menu_overview_form().

Adds an anchor tag so we can link to a menu item directly from the node form.

See also

menu_link_weight_node_element_process

File

./menu_link_weight.module, line 92
Replaces the menu link weight dropdown with a tabledrag widget.

Code

function menu_link_weight_form_menu_overview_form_alter(&$form, &$form_state) {
  foreach (element_children($form) as $element) {
    if (substr($element, 0, 5) == 'mlid:') {
      $mlid = $form[$element]['#item']['mlid'];

      // Add an offset of 60 pixels to the anchor tag so it doesn't "headbutt"
      // the top of the screen.
      $html = '<span style="display: inline-block; margin-top: -60px; padding-top: 60px;" id="menu-link-weight-mlid-' . $mlid . '"></span>';
      $form[$element]['title']['#prefix'] = isset($form[$element]['title']['#prefix']) ? $form[$element]['title']['#prefix'] . $html : $html;
    }
  }
}