User login

Having the top-level menu items not be links (for use with dropdown menus)

The best approach may be to avoid this entirely with proper information architecture. I always try to make these have meaning themselves, but certainly with not expecting most people to click on them anyway, this does not always make sense. Instead, the way Agaricer Kathleen did it for one project is simply to have each dropdown be a separate menu.

But let's say you are stubborn and don't like that approach or are too far down the path of a big old nested primary links menu. What do you do? Call Agaric, of course (or find this web page).

to Agaricer Dan:
The only thing, according to you, that you'd like to change is the variable $link['href'], that which is put in after <a href=" in a formatted link. Correct? Therefore, all you have to do is change that one variable before returning the link. So add the if statement that checks for fakelink and set $link['href'] = '#'; ...I'm not sure what the l() function does to a lonely # though, so you may want to construct your link manually, in which case you would have to call your own return. But the shorter 3 line change is worth trying before longer 3 line change.

Reference

Menu items that are not links
http://drupal.org/node/143322#comment-1216322

http://drupal.org/node/128618

none of this worked for me

this module did not either :( http://drupal.org/project/special_menu_items

prolly coz i have special stuff to add spans to my links...
like this

<?php
function agaricclient_menu_item_link_spanned($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
   $link['title'] = '<span class="menutab">' . check_plain($link['title']) . '</span>';
   $link['localized_options']['html'] = TRUE;
  return l($link['title'], $link['href'], $link['localized_options']);
}

i'd love to get this to work on it but it didnt

if($link['href'] == "<front>")    {
    return "<a href="#">$link[title]</a>";
    }
    else
    {
      return l($link['title'], $link['href'], $link['localized_options']);
    }
?>

Resolution

Searched words: 
and that is for putting it right before the existing return statement. If you want to do it first drupal module menus nonlinks Jquery disable top-level menu links CSS make link not clickable CSS disable link drupal make top-level menus not a link jquery disable links

Comments

Agaricer? You mean Agaric?

as in my fellow agaric Ben, is making up funny words :P

anyway, here is code that works perfectly

<?php
function ventus_menu_item_link_spanned($link) {

  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
   $link['title'] = '<span class="menutab">' . check_plain($link['title']) . '</span>';
   $link['localized_options']['html'] = TRUE;
  //return l($link['title'], $link['href'], $link['localized_options']);
 
  if($link['href'] == "http://nolink")    {
    return "<a href='#'>" . $link[title] . "</a>";
    }
    else
    {
    return l($link['title'], $link['href'], $link['localized_options']);
    }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.