Agaric Design Collective

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

By Benjamin Melançon
on 27 May
1 comment

Key words and phrases

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

Tags

Description

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]);
    }
?>

 

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']);
    }
}
?>

Posted by Dan Hakimzadeh on Fri, 2009-05-29 16:57
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.