You are here

function dhtml_menu_theme_menu_item_link in DHTML Menu 6.3

Same name and namespace in other branches
  1. 8 dhtml_menu.theme.inc \dhtml_menu_theme_menu_item_link()
  2. 6.4 dhtml_menu.theme.inc \dhtml_menu_theme_menu_item_link()

Preprocessor for menu_item_link. Adds an ID attribute to menu links and helps the module follow the recursion of menu_tree_output().

1 string reference to 'dhtml_menu_theme_menu_item_link'
dhtml_menu_update_6003 in ./dhtml_menu.install
#6003: 6.x-3.4 upgrade. Remove two obsolete variables and rebuild all themes.

File

./dhtml_menu.module, line 54
dhtml_menu.module Adds preprocessors to the menu theming functions that will add dynamic expansion to their menus.

Code

function dhtml_menu_theme_menu_item_link($link) {

  // Find out which theme function to dispatch to after preprocessing.
  global $theme;
  static $disabled, $function;
  if (!isset($disabled)) {
    $disabled = variable_get('dhtml_menu_disabled', array());
    $registry = variable_get('dhtml_menu_theme', array());
    $function = isset($registry[$theme]) ? $registry[$theme]['menu_item_link'] : 'theme_menu_item_link';
  }

  // Only work with menu items that have an mlid and a menu name.
  if (isset($link['menu_name']) && isset($link['mlid'])) {

    // Some themes use options, others use localized_options. Populate both.
    $link['localized_options']['attributes']['id'] = 'dhtml_menu-' . _dhtml_menu_unique_id($link['mlid']);
    $link['options']['attributes']['id'] = $link['localized_options']['attributes']['id'];

    // Disabled items are now marked. They must still be added to the stack to pass information within this module.
    if (!empty($disabled[$link['menu_name']])) {
      $link['dhtml_disabled'] = TRUE;
    }

    // Stack this item to track the recursion levels.
    _dhtml_menu_stack($link);
  }

  // Pass the altered variables to the normal menu themer.
  return $function($link);
}