menu_form_alter

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/menu/menu.module, строка 359

Версии
5
menu_form_alter($form_id, &$form)
6
menu_form_alter(&$form, $form_state, $form_id)

Implementation of hook_form_alter(). Adds menu item fields to the node form.

Код

<?php
function menu_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
    // Note - doing this to make sure the delete checkbox stays in the form.
    $form['#cache'] = TRUE;

    $form['menu'] = array(
      '#type' => 'fieldset',
      '#title' => t('Menu settings'),
      '#access' => user_access('administer menu'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#tree' => TRUE,
      '#weight' => -2,
      '#attributes' => array('class' => 'menu-item-form'),
    );
    $item = $form['#node']->menu;

    if ($item['mlid']) {
      // There is an existing link.
      $form['menu']['delete'] = array(
        '#type' => 'checkbox',
        '#title' => t('Delete this menu item.'),
      );
    }
    if (!$item['link_title']) {
      $form['menu']['#collapsed'] = TRUE;
    }

    foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) {
      $form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
    }
    $form['menu']['#item'] = $item;

    $form['menu']['link_title'] = array('#type' => 'textfield',
      '#title' => t('Menu link title'),
      '#default_value' => $item['link_title'],
      '#description' => t('The link text corresponding to this item that should appear in the menu. Leave blank if you do not wish to add this post to the menu.'),
      '#required' => FALSE,
    );
    // Generate a list of possible parents (not including this item or descendants).
    $options = menu_parent_options(menu_get_menus(), $item);
    $default = $item['menu_name'] .':'. $item['plid'];
    if (!isset($options[$default])) {
      $default = 'primary-links:0';
    }
    $form['menu']['parent'] = array(
      '#type' => 'select',
      '#title' => t('Parent item'),
      '#default_value' => $default,
      '#options' => $options,
      '#description' => t('The maximum depth for an item and all its children is fixed at !maxdepth. Some menu items may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
      '#attributes' => array('class' => 'menu-title-select'),
    );
    $form['#submit'][] = 'menu_node_form_submit';

    $form['menu']['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight'),
      '#delta' => 50,
      '#default_value' => $item['weight'],
      '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
    );
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему