[support] Menu item to outside URL
Carl Parrish
lists at pcl-consulting.com
Fri Mar 10 15:38:35 UTC 2006
Gordon Heydon wrote:
>Hi,
>
>On Sat, 2006-02-25 at 15:42 -0700, Carl Parrish wrote:
>
>
>>How do you create a menu with link to a url not on your server?
>>
>>
>
>This depends on which version of Drupal. If you are using 4.6 then you
>the start menu system can't do it.
>
>However if you are using 4.7, then this will not a problem.
>
>Gordon.
>
>
>
Here is my dirty hack. I'm not posting a patch because it seems like
this has already been solved in 4.7 and well its pretty bad. I'm posting
to the mailing list because
1) perhaps someone who knows this stuff better than I do will see
something stupid I did and can point it out to me before my system gets
owned or something
2) just in case someone else needs a dirty hack for 4.6
Okay this is what I did, in common.inc I created a function called
external_l()
/**
* External Link
* Dirty hack to allow me to do outside links from menus
*
*/
function external_l($text, $path){
return '<a href="'.$path .'">' . $text .'</a>';
}
Then in menu.inc starting at line 607 I made the following changes to
theme_menu_item_link()
607 function theme_menu_item_link($item, $link_item) {
608 if(substr($link_item['path'], 0, 4) == 'http'){
609 $my_link = external_l($item['title'], $link_item['path']);
610 }else{
611 $my_link = l($item['title'], $link_item['path'],
array_key_exists('description', $item) ? array('title' =>
$item['description']) : array());
612 }
613 return $my_link;
614 }
l() handles a *lot* more than external_l() currently does, perhaps I'll
get around to looking some of those functions up and deciding if I need
them or not. But for now it does what I need.
More information about the support
mailing list