Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you mouse over the nolink menu item in the main menu, the url shown is "example.com/" and clicking twice quickly (imitating a user thinking the first click didn't register) directs them to "example.com/" which, of course, registers as "Page not found". I also tried using "" and same result...
Dev site is located at bhs.cfaa.co and the official site will be located at bhsfinancialwellness.com when ready.
Btw, I noticed that there was a Drupal 6 issue with this. Could the problems be related?...
Comment | File | Size | Author |
---|---|---|---|
#32 | superfish_special_menu_items.patch | 1.38 KB | peterx |
Comments
Comment #1
george.plescan CreditAttribution: george.plescan commentedI also notice this in the 7.x-1.0 version of the module. I install the module and I use nolink for a dropdown menu item. The result is a link to a nolink page, not found.
I have several modules installed, but i don't think there might be conflicts, except with the nice menus module.
Hope we can get any help on this as this bug is a module breaker.
PS: I tried editing the comment to show the nolink with smaller and greater, but I don't know how ?
Comment #2
iaminawe CreditAttribution: iaminawe commentedI can confirm this bug
Comment #3
nordicmaterial CreditAttribution: nordicmaterial commentedI can confirm too.
Result is "a href="thepathofthewebsite/drupal/%3Cnolink%3E" in the menu item instead of omitting the a- tag.
Subscribing.
Comment #4
michaelgiaimo CreditAttribution: michaelgiaimo commentedConfirm. Subscribe.
Comment #5
agerard CreditAttribution: agerard commentedconfirm, subscribe, hope.
Comment #6
erok415 CreditAttribution: erok415 commentedSub
Comment #7
fizzbin CreditAttribution: fizzbin commentedsubscribing.
IMHO there should not even have to *BE* a special module for this functionality, this should have gone straight to core a long time ago. The trouble with having hover-based expand interactions (like Superfish menus) clickable is that on an iPad or similar device, how does one "hover"? On these devices you are therefore restricted to one level of menu item, the top-level items.
Comment #8
erok415 CreditAttribution: erok415 commentedI second that.
Comment #9
timofey CreditAttribution: timofey commented+subscribing
UPDATE: The problem is caused in combination with a SuperFish menu module. It does work in regular menus.
Comment #10
erok415 CreditAttribution: erok415 commentedI'm using Nice Menu's and nesting Menu Minipanels. The result is / instead of nothing happening.
E.
Comment #11
timofey CreditAttribution: timofey commentedok, so I researched the problem... and it seems like an ugly one....
Basically SuperFish and other menu modules rewrites the menu structure, and some even force menu items as links, therefore any functions passed to the menu don't get counted in. :( sad. There are many posts relating to this:
http://drupal.org/node/1190688
http://drupal.org/node/1007054
Because it gets rewritten and to the fact that we're forced to have menus as links, the only solution I see on the side of Special Menu, is to attach '#' as a 'link_path' attribute.
see http://drupal.org/node/1221294
You can also manually edit superfish.module (not recommended) and change:
into
Reset Cache
UPDATE: to copy the
<a>
attributes to the new<span>
, see post #25.Comment #12
erok415 CreditAttribution: erok415 commented@timofey
Do you have any idea of how to do this with Nice Menus? I know it is a branch of Superfish but the code you have doesn't match the code in nice_menus.module. Any help would be much appreciated because I have a bunch of menu items that I need to disable.
E.
Comment #13
timofey CreditAttribution: timofey commented@erok415
For this, you'll need to edit nice_menus.module (in nice_menus module directory)
Option #1.
[removed] - use the second option.
Option #2, replace this :
with this:
Reset Cache
Code updated per Post #16
Comment #14
erok415 CreditAttribution: erok415 commented@timofey
Will do and thanks for the help. I'll report back right away.
E.
Comment #15
erok415 CreditAttribution: erok415 commented@timofrey
First, thanks so much for helping out. It's people like you that makes using Drupal a blast.
I tried using the first option and when I enter it in, I get a syntax error (using Dreamweaver CS5.5 as my editor). I'm not to adept at writing JS so I wasn't going to try to fix it. It looks to me like the structure of your code vs. the code I'm replacing is off though. Here is a snippet of code that I'm replacing which is in two areas.
The code below comes from the module Nice Menus ver. 7.x-2.0
Starting at line 448 in nice_menus.module
Starting at line 471 in nice_menus.module
I replaced line 575 with your option 2 and unfortunately I'm still getting /. I even flushed my cache even though I'm not caching due to being in development mode. The
<span>
tag is not getting wrapped around the<a>
tag.Here is the code as it stands with your suggestions.
Comment #16
Morasta CreditAttribution: Morasta commented@ #13,
Got it working with option #2 D7, latest everything. Go into nice_menu.module and scroll to the very bottom and comment out the line timofey mentioned. Then copy and paste his solution into the module. I made one change here: on the if line I check for what the module instructs you to enter.
if ($variables['element']['#href'] == '<nolink>') {
Had to flush my site's cache to pick up the changes, but now it's great. Many thanks for the easy solution.
Comment #17
timofey CreditAttribution: timofey commented@Morasta, thanks for the feedback! I corrected the code.
@erok415, try #13 again. It should work now.
You can see a working versions of the modified superfish.module here cityhill.timofey.com.
Site only tested with latter version of Chrome & FF.
Comment #18
gagarine CreditAttribution: gagarine commentedComment #19
erok415 CreditAttribution: erok415 commented@timofey
Darn I just typed my whole response and then clicked on your example site, which by the way is way cool for a church. Then I lost all of my response.
Rather than writing it all over again with examples, I will keep it short.
Your code removes all of if any id's, styles and any other attributes that were part of the
<a>
tag which code determine how the navigation looks.E.
Comment #20
erok415 CreditAttribution: erok415 commented@timofey,
I did it!...and it was much easier than I thought it would be. I reviewed your syntax and the .module file again and looked at your code suggestions (#13) again. I found that if I use your final return line with a slight modification to send #href a '#', my problem was solved. So here it is and tested.
Notice using the bottom return with a slight modification. When I used your original code, it returned a
<span class="nolink">#title</span>
. Which stripped out all of the styles, classes and id's from the tag. That didn't work and made it look horrible.With my modification, I'm returning all of the original attributes using #localized_options, including the #title. The line
$variables['element']['#href'] = '#'
replaces with #. If you click this link, it will take you now to the homepage or root.Well thank you for working with me to find a solution to Special Menu module working with Nice Menu module. Now they play nice. I hope others will find this useful.
E.
Comment #21
timofey CreditAttribution: timofey commented@erok415
The l($title, $url, $attributes) converts the stuff into
<a $attributes href="$url">$title</a>
. Converting a nolink into blank URL(<a $attributes href="">$title</a>
) is not html/browser compliant... it won't work in many scenarios & browsers.try this, this will convert the
<a $attributes href="$url">$title</a>
into<span $attributes>$title</span>
:I don't think there are any
id
attributes passed... so we're only moving classes, but it there are, you can do this:Comment #22
erok415 CreditAttribution: erok415 commented@timofey
Although your solution may meet most goals, It seems that I'm not making my point. I need to keep the
<a>
included in the code so that the dropdown works.However, I will try it, change my style sheet to include this new structure and report back.
E.
Comment #23
erok415 CreditAttribution: erok415 commented@timofey
I didn't realize that my breadcrumbs are not included in this retrofit. My breadcrumbs are still displaying
/<nolink>
. I'll have to work on that one to.Any suggestions?
E.
Comment #24
Scipr CreditAttribution: Scipr commented@timofy
The look of my superfish menu item is gone when I manually edit the code of superfish.module (#11). Is there a way to keep the look of the item?
Thanks.
Comment #25
timofey CreditAttribution: timofey commented@erok415
Sorry, i don't have nice-menus installed. I can't test it.
@Scipr
The old code:
replace with the new code:
Basically, you carry over the attributes ($link_options) from the old menu item into your new nolink menu item.
You may have to also modify css. If superfish directly styles the
<a>
tags, you'll need to modify the css to also include the<span>
tags.Comment #26
phoenix CreditAttribution: phoenix commentedHaving the same problem. I have the superfish module and this results in
<a href="/%3Cnolink%3E"...
Comment #27
Bitbull CreditAttribution: Bitbull commentedsubscribing (same issue with marinelli theme and megadropdown for main menu activated - - no other module involved!)
Comment #28
gagarine CreditAttribution: gagarine commentedI will love to see first witch direction we can't take for #1287610: Create a Menu Item Type API. Sadly other maintainers didn't answer neither users.
We can fix for XY module but is going to break every time we have a new module. I don't want that...
If we make an more generic module (like token) we can provide:
1) A way for other module to integrate
2) a option to create "fake link" with some JS in case the module doesn't provide a good integration
And the code than manage menu link can be all in one place.
So I put as postponed until some peoples give me some review about it (please do in #1287610: Create a Menu Item Type API).
Comment #29
kingfisher64 CreditAttribution: kingfisher64 commentedI'm using the solution (temporary patch) for superfish provided by timofey in #11.
One thing worth mentioning for the superfish temp fix, to achieve the same look as the default menu style add the following code to superfish.css in sites/all/libraries/css/superfish.css
I obviously don't like editing another module to get to this solution - even though it works great, does anybody know who far along a permanent solution is?
Edit
Referenced wrong post number.
Comment #30
timofey CreditAttribution: timofey commented@kingfisher64
post #13 is actually for nicemenus; superfish is posts #11 and #25 :)
Comment #31
sifaan CreditAttribution: sifaan commentedto match the look of other menus (with links) you actually have to consider the theme you are using; e.g. I am using Sky, which has rounded borders on the top, etc, so the following css worked better for me:
Comment #32
peterx CreditAttribution: peterx commentedSuperfish 7.x-1.8 patch posted in http://drupal.org/node/1148028#comment-5305848
Comment #33
universalhandle CreditAttribution: universalhandle commentedFor Nice Menus check out this patch I just posted: http://drupal.org/node/1216372#comment-5311044. Please test and review; let's see if we can get this committed!
Comment #34
gabri86 CreditAttribution: gabri86 commentedI replace with this code to avoid having to modify the css
This way we have a label
<a>
but not href=""Tell me if I'm wrong.
P.S.: Sorry for my bad english, Google translate don't help me so much
Comment #35
cokreza CreditAttribution: cokreza commentedThank you..
I add this in my template.php, and it's works!
Comment #36
sigismo CreditAttribution: sigismo commentedI was able to do something similar with a preprocesseor for Superfish, I guess it could be modified for nice menus as well. Here's my template.php.
//No link hack
function nroj_preprocess_block(&$variables){
$markup = $variables['content'];
$needle = '<a href="/%3Cnolink%3E" title="" class="sf-depth-1 menuparent">Distilleries</a>';
$replace = '<a title="" class="sf-depth-1 menuparent nolink ">Distilleries</a>';
$new_markup = str_replace($needle, $replace, $markup);
$variables['content'] = $new_markup;
}
Comment #37
ykyuen CreditAttribution: ykyuen commented#35 can solve the conflict between Nice menus and Special menu items module. Thanks!
Comment #38
gmangones CreditAttribution: gmangones commentedExcelent answer, thank so much, to me worked perefect..
Comment #39
gmangones CreditAttribution: gmangones commentedHello, this answer for me is better than before. worked perfect. but i changed "#" by "javascript:". ready.
Comment #40
upunkt CreditAttribution: upunkt commentedIn addition to the great #35, picking up erok415's remark in #23, that breadcrumbs still have nolink-tags.
After considering adding a "#" I realized, that linked breadcrumbs are completely unnecessary, except for the "Home"-Link. The solution is inspired by http://www.atlanticbt.com/blog/how-to-add-custom-fields-to-drupal-7-brea...
Putting the following into template.php is working for me. Drupal 7, "Basic"-Theme. This theme has already a "function YOURTHEME_breadcrumb($variables)", just put the code inside.
I bet all could be written more elegant, but I believe elegancy is something that many of the readers of these comments don't put on their personal top#1 in real life. Author included.
Comment #41
erok415 CreditAttribution: erok415 commentedHi,
I thought I solved this problem but the dog won't bite. I want to insert a onclick="return false" into the tag of each of my nav items. Here's my code. This solves removing the from the href but it places a "/" or root link in the href. For people who like to click on navigation items, this is very frustrating as it keeps taking them back to the root of the site (homepage). This obviously needs to be fixed. My solution is in the next comment.
Thanks for the help.
E.
Comment #42
erok415 CreditAttribution: erok415 commentedThe fix below removes the from the href and places a onclick="return false" inside the
<a
tag. This disables navigation items from going anywhere.I figured it out. It's weird but it seemed to help to have the localized_options onclick in both the $showme and the return a few lines down. If anyone can explain it to me that would be great. Because when I tested the code with only one or the other, it didn't work. But when I used them together, it worked but only after the first reference to the onclick in the $showme line. Go figure!
The code above was tested in the nice_menus.module and worked. Surely, modifying the .module code is not a good idea and you would want to create a patch. ...or you could simply place this code in your template.php file inside your theme with a tiny modification. See below...
Sources that helped:
http://bit.ly/zMZ6Uo
http://bit.ly/yPcbvs
http://bit.ly/zqqc50
Question: Can anyone explain why the onlclick is required in both the $showme and the return?
Comment #43
Anonymous (not verified) CreditAttribution: Anonymous commentedI am using the most recent Superfish menu module for D7 in the latest version of D7 and the latest special menu items module for D7, and had an issue using on parent menu items ( I would get a page not found error when visiting the parent link) and this worked like a charm for me.
Link: http://drupal.org/node/1447988
I downloaded this file which replaces the default my special_menu_items.module file in the special menu items module folder (located in sites/all/modules/special_menu_items/) and then had to add .menuparent class to my various css files since I found that once the above file was replaced my menu link wasn't being styled properly. Now the works like a charm. I hope this helps anyone struggling with this issue as it's been a week trying to find a resolution. Thank you to mehrpadin for posting the fix.
Comment #44
CodigoVision CreditAttribution: CodigoVision commentedUsing Superfish:
Made a small change to #36 to make it more universal and it worked great!
Comment #45
aubjr_drupal CreditAttribution: aubjr_drupal commentedAfter looking at the work done throughout this thread, including the latest work at #42 and #44, I installed the Special Menu Items module and was going to try making a mix of those solutions work in template.php.
However, after a couple of failed attempts, I tried something that was so simple that I thought, "That just can't work": I went into /admin/config/system/special_menu_items and set the 'HTML tag for "nolink"' to <a> (the anchor tag) - and it worked! It kept the Nice Menus structure and dropdowns, etc.
Caveat: This workaround does not work with breadcrumbs (you get <nolink> for your destination URL).
Comment #46
wrg20 CreditAttribution: wrg20 commentedI just used JQuery to disable the link and make it black.
Comment #47
Screenack CreditAttribution: Screenack commentedAs I'm using Superfish, this affects my usage. Like wrg20, I found jQuery an effective work around: http://css-tricks.com/snippets/jquery/disable-parent-links-in-nested-lis...
Comment #48
gagarine CreditAttribution: gagarine commentedstill a problem on the 2.x branch?
Comment #49
gagarine CreditAttribution: gagarine commentedComment #50
imclean CreditAttribution: imclean commented7.x-2.x-dev looks good to me, thanks.
Comment #51
gagarine CreditAttribution: gagarine commentedComment #54
jsimonis CreditAttribution: jsimonis commentedI'm using nice menu and I'm still getting this. I've tried the dev version and I've tried the last fix listed above for nice menu.
Comment #55
jsimonis CreditAttribution: jsimonis commentedIf I try the jquery method mentioned above, where would I put that?