Return to Snippet

Revision: 7792
at August 13, 2008 08:35 by shrop


Initial Code
<?php
/**
* Override theme_menu_item_link
* <a href="http://api.drupal.org/api/function/theme_menu_item_link/5
" title="http://api.drupal.org/api/function/theme_menu_item_link/5
">http://api.drupal.org/api/function/theme_menu_item_link/5
</a> */
function phptemplate_menu_item_link($item, $link_item) {
    // make external links open in new windows    
    $attributes = !empty($item['description']) ? array('title' => $item['description']) : array();
    if (strpos($link_item['path'], 'http://') === 0 || strpos($link_item['path'], 'https://') === 0) {
        $attributes['target'] = '_blank';
    }
  return l($item['title'], $link_item['path'], $attributes, isset($item['query']) ? $item['query'] : NULL);
}
?>

Initial URL
http://agaricdesign.com/note/open-external-urls-a-new-window

Initial Description
PHP Template override by Benjamin Melançon of Agaric Design.

Initial Title
Open external URLs in a new window - Drupal

Initial Tags
drupal

Initial Language
PHP