You are here

function custom_breadcrumbs_theme_menu_item_link in Custom Breadcrumbs 6.2

Same name and namespace in other branches
  1. 7.2 custom_breadcrumbs.module \custom_breadcrumbs_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().

Parameters

$link: A menu link.

1 string reference to 'custom_breadcrumbs_theme_menu_item_link'
custom_breadcrumbs_theme_registry_alter in ./custom_breadcrumbs.module
Implements hook_theme_registry_alter().

File

./custom_breadcrumbs.module, line 928
Provide custom breadcrumbs for node-type pages and base functionality for submodules to add custom breadcrumbs for other types of pages.

Code

function custom_breadcrumbs_theme_menu_item_link($link) {

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

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

    // Each link in series is another level of recursion. Add it to the stack.
    _custom_breadcrumbs_menu_stack($link);
    if (custom_breadcrumbs_in_active_trail($link)) {
      $link['localized_options']['attributes']['class'] = 'active';
    }
  }

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