You are here

function menu_target_preprocess_menu_link in Menu target 7

Implements hook_menu_link().

See also

_menu_target_retarget_link()

File

./menu_target.module, line 61
Allows content editors to choose wether or not to open menu items in a new window

Code

function menu_target_preprocess_menu_link(&$variables) {

  // Li container attributes
  // $variables['element']['#attributes']
  // link attributes
  // $variables['element']['#localized_options']['attributes']
  // Should we add attributes to this link?
  if (_menu_target_retarget_link($variables['element']['#original_link']['mlid'])) {
    $targeting = variable_get('menu_target_type', 'html');

    // What kind of attributes depend on the settings
    if ($targeting == 'html') {
      $variables['element']['#localized_options']['attributes']['target'] = "_blank";
    }
    else {
      $variables['element']['#localized_options']['attributes']['class'][] = "target-blank";
    }
  }
}