Posted by archard on March 4, 2008 at 5:49am
4 followers
Jump to:
| Project: | Nice Menus |
| Version: | 5.x-1.2 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I'd like to make all the parent menu items in my nice menu unclickable because usually the parent item is a generic category that doesn't have a destination. There doesn't seem to be a way to do this in the menu administration area. Is there a way I can do this with css or maybe even... *gulp*.... javascript?
Comments
#1
Under the customization section of the nice menus handbook (http://drupal.org/node/185543) there is a link to make non-clickable parents, and yes it does use JS. If you find another way that this could be accomplished, please share your find.
#2
I think I figured out how to do it without javascript.
I found this node from the link you gave me: http://drupal.org/node/143322
It says you can put this code in your template.php file and make the link "
<none>" to make it unlinkable.<?phpfunction phptemplate_menu_item_link($item, $link_item) {
if ($item['path'] == '<none>') {
$attributes['title'] = $link['description'];
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);
}
}
?>
That turned out kinda weird for me and didn't allow me any dropdrown capabilities. So I just changed the
<span></span>tags to<a></a>tags and it appears to work fine. I haven't tested it thoroughly yet but it seems to be working correctly. I'm using this on the primary links menu, btw.#3
Automatically closed -- issue fixed for two weeks with no activity.
#4
Thanks, this is just what I needed.
Works perfectly!
#5
Perhaps nice menus has changed since this post, throws an error about the second parameter. I imagine this was create for the D5 version?
warning: Missing argument 2 for phptemplate_menu_item_link() in /var/www/mysite/sites/all/themes/mytheme/template.php on line 195.
This would be a great snippet. Anymore more familiar with this module?