Return to Snippet

Revision: 8015
at August 26, 2008 20:29 by aleprieto


Initial Code
<?php
function phptemplate_menu_item_link($item, $link_item) {
  if ($item['path'] == '<none>') {
    $attributes['title'] = $link['description'];
//  Here you can specify a '#' link or wathever you want:
//  return '<a'. drupal_attributes($attributes) . 'href="#">'. $item['title'] .'</a>';
    return '<span'. drupal_attributes($attributes) .'>'. $item['title'] .'</span>';
  }
  else {
    return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
  }
}
?>
<?php
/*
* As a nice extra, we can also add additional help text to the menu item edit page. For that * you will need to implement a very small module that implements form_alter.
* The module itself doesn't need anything more than the following code snippet:
*/
function example_form_alter($form_id, &$form) {
  if ('menu_edit_item_form' == $form_id) {
    $form['path']['#description'] .= ' ' . t('Enter %none to have a menu item that generates no link.', array('%none' => '<none>'));
  }
}
?>

Initial URL
http://drupal.org/node/143322

Initial Description
The following code lets us designate "menu links" that will not actually link anywhere.

Initial Title
Menu items that are not links

Initial Tags
template, drupal

Initial Language
PHP