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