You are here

function menu_attributes_menu_attribute_info in Menu Attributes 8

Same name and namespace in other branches
  1. 6.2 menu_attributes.module \menu_attributes_menu_attribute_info()
  2. 6 menu_attributes.module \menu_attributes_menu_attribute_info()
  3. 7 menu_attributes.module \menu_attributes_menu_attribute_info()

Implements hook_menu_attribute_info().

File

./menu_attributes.module, line 41
Alters the menu item form to allow the administrator to specify additional attributes for the menu link

Code

function menu_attributes_menu_attribute_info() {
  $info['title'] = [
    'label' => t('Title'),
    'description' => t('The description displayed when hovering over the link.'),
    'form' => [
      '#type' => 'textarea',
      '#rows' => 2,
    ],
    'scope' => [
      MENU_ATTRIBUTES_LINK,
    ],
  ];
  $info['id'] = [
    'label' => t('ID'),
    'description' => t('Specifies a unique ID for the link.'),
    'item_description' => t('Specifies a unique ID to be added to the item.'),
    'scope' => [
      MENU_ATTRIBUTES_LINK,
      MENU_ATTRIBUTES_ITEM,
    ],
  ];
  $info['name'] = [
    'label' => t('Name'),
    'scope' => [
      MENU_ATTRIBUTES_LINK,
    ],
  ];
  $info['rel'] = [
    'label' => t('Relationship'),
    'description' => t("Specifies the relationship between the current page and the link. Enter 'nofollow' here to nofollow this link."),
    'scope' => [
      MENU_ATTRIBUTES_LINK,
    ],
  ];
  $info['class'] = [
    'label' => t('Classes'),
    'description' => t('Enter additional classes to be added to the link.'),
    'item_description' => t('Enter additional CSS class names to be added to the item.'),
    'scope' => [
      MENU_ATTRIBUTES_LINK,
      MENU_ATTRIBUTES_ITEM,
    ],
  ];
  $info['style'] = [
    'label' => t('Style'),
    'description' => t('Enter additional styles to be applied to the link.'),
    'item_description' => t('Enter additional styles attribute to be applied to the item.'),
    'scope' => [
      MENU_ATTRIBUTES_LINK,
      MENU_ATTRIBUTES_ITEM,
    ],
  ];
  $info['target'] = [
    'label' => t('Target'),
    'description' => t('Specifies where to open the link. Using this attribute breaks XHTML validation.'),
    'form' => [
      '#type' => 'select',
      '#options' => [
        '' => t('None (i.e. same window)'),
        '_blank' => t('New window (_blank)'),
        '_top' => t('Top window (_top)'),
        '_self' => t('Same window (_self)'),
        '_parent' => t('Parent window (_parent)'),
      ],
    ],
    'scope' => [
      MENU_ATTRIBUTES_LINK,
    ],
  ];
  $info['accesskey'] = [
    'label' => t('Access Key'),
    'description' => t('Specifies a <a href=":url">keyboard shortcut</a> to access this link.', [
      ':url' => 'http://en.wikipedia.org/wiki/Access_keys',
    ]),
    'form' => [
      '#maxlength' => 1,
      '#size' => 1,
    ],
    'scope' => [
      MENU_ATTRIBUTES_LINK,
    ],
  ];
  return $info;
}