How do you create links with a NULL or # in Drupal?
Solution 1
I always use the Special Menu Items module, which allows you to enter "nolink" as path. A 'nolink' menu item will render as a normal menu item without <a>
tag, but you can style it differently if needed.
Solution 2
$("#block-menu_block-1 li.expanded > a").removeAttr("href");
I use this to get rid of href of the first level of li a. This makes it possible to use the first a links in a menu as non click able categories. This is a bit ugly but it works for smaller things :)
Solution 3
You could just make a bogus link to anything, perhaps the homepage and then use jQuery to turn off the click by adding something like this:
$('.menu-item-classorID').click(function(){ return false; });
Quick and dirty method but does the trick in a pinch. Use menu attributes module to add class or ID to a menu item.
Solution 4
Http://#
Drupal takes it as input, but it returns an error in the navigation, but at least I've got a menu item. Posting this for now until someone post an answer that Drupal 6 takes as input, and does not produce an error.
Related videos on Youtube
Cesar
Updated on September 17, 2022Comments
-
Cesar over 1 year
Trying to create folders for links where the parent has no content, it's just a folder. Need to be able to insert #, but Drupal is saying it's not a link. Just want the user to click it and nothing happen, the child of that menu item will already be being displayed without a click.
Version: Drupal 6 (appears worked in D5)
I've attempted the following:
'', #, <#>, empty, <empty>, null, <null>, blank, <blank>, <none>, none, <answer>
...just kidding.ERROR: The path '
<insert_non-url>
' is either invalid or you do not have access to it.Question, just ask -- thanks!
-
John Conde over 13 yearsThis would be better as an edit to your question or a comment since it's not actually an answer.
-
Cesar over 13 years@John Conde: I'm using it as an answer for now, meaning at the very least I'm able to create place holders, and move forward until I find a better answer.
-
Cesar over 13 years+1 I've seen that mod, but super hard to tell if it'll work with the system I have in place, or even worse create a conflict... guess I'll give it a try. Thanks!
-
Cesar over 13 yearsYep, got some crazy error message "user warning: Duplicate entry"... :-) ...lucky it went away after I delete the mod.
-
marcvangend over 13 yearsHmmm, that makes me wonder which modules you have enabled. I never had incompatibility problems with special menu items.
-
paulmorriss over 12 yearsOne common was is to link like this: href="#". That does nothing.
-
Dan Bolser over 9 yearsRe-problems with Special Menu Items, lots of people are having issues simply because you need to clear all caches after installing it for it to work!