special menu items is designed right now so that it renders a "nolink" as a <span>.
this causes other modules that rely on an <a href="..."> menu item to break.
like:
* menu attributes
* megamenu
* superfish
...
so i propose to render "nolink" items as <a href="#" class="nolink">
so other modules see what they expect.
this "nolink" can then be altered by a onload javascript oneliner which makes it a span.
the downside of this is that users without javascript see a nolink as a link (which does nothing) when hovering over it - but i think this is neglegible against a flood of issues like "special menu items does not play well with module XYZ".
Comments
Comment #1
geek-merlinComment #2
gagarine CreditAttribution: gagarine commentedI'm not to add links than is not. They are perhaps an other way to fix the issue.
Someone can confirm is still breaking in D7?
Comment #3
geek-merlinright, this may cause issues so should be an option.
Comment #4
geek-merlinsee also: #1190688: Superfish not compatible with Void Menu - Forces link attributes.
and several posts in #1007054: Drupal 7 version of Special menu items module
(#53,56,57,68)
Comment #5
gagarine CreditAttribution: gagarine commentedOk for an option. Patch welcome.
Comment #6
gagarine CreditAttribution: gagarine commentedComment #7
candelas CreditAttribution: candelas commentedany news?
Comment #8
gagarine CreditAttribution: gagarine commentedI just raise the issue to major.
If you absolutely need the feature make a patch or consider sponsoring it (money make everything faster).
Comment #9
erok415 CreditAttribution: erok415 commentedsub
Comment #10
aburnsni CreditAttribution: aburnsni commentedsubscribe
Comment #11
3dinfluence CreditAttribution: 3dinfluence commentedI've worked around this issue for the time being by adding the following javascript to my theme template. It's a hack at best but gets me past my last remaining issue preventing me from migrating a site to D7 until a real fix is released.
Here's the work around.
In your html.tpl.php for your theme find the line that says
And add the following just after it.
Then you need to flush your sites caches for the change to take effect. This only works for the nolink menu items. With a few tweaks it shouldn't be difficult to extend this to work for separators.
EDIT: I modified the script to support separators. Note that this will only work if javascript is enabled by the client. It replaces nolink menu items with span tags and the separators with hr tags.
Comment #12
Yaazkal CreditAttribution: Yaazkal commentedHi, the code on #11 should be:
Just replace
<$("[href=
with
$("a[href$=
that's the way it works.
Thanks 3dinfluence
Regards !
PS: This solution should be on the module and no as a JS. But if you need it urgent (as I) this JS is just fine. This must be a feature on this module.
Comment #13
3dinfluence CreditAttribution: 3dinfluence commentedIt seems to work fine without specifying the a tag in the selector here. Although I'll agree that it's probably more efficient this way as jQuery doesn't have to look for href attributes for every object in the DOM.
I also agree this is just a hack. The real solution will have to be integrated into the module.
Comment #14
3dinfluence CreditAttribution: 3dinfluence commentedAlternatively if you don't want to modify your templates you can add this script by saving it without the
tags to a .js file and add it to your theme by adding a line like this example to your themes.info file.
scripts[] = js/nolink_fix.js
Comment #15
Yucom CreditAttribution: Yucom commentedThanks for the JS. It was really helpful, and did what I needed. I am using the superfish-module, so I did a few changes to the script, not much, and not that I know what I am doing here, as I am not skilled with JS. I changed the "span" into an "a" again, as if you use a span, the superfish css doesn't fit anymore. Yes you can change the whole css, but for what?
Important - I am using this only for the very first parent item of a menu, the visible part. Please stick to the solution Yaazkal if you want to be on the save side!
Comment #16
fahadurrehman CreditAttribution: fahadurrehman commentedI am using special menu item since drupal 6. it allows you to simply put nolink as a path into menu items. I cant understand why drupal don't allows # to be entered as a link. To over come this problem and some other similar problems I usually add a Jquery file in my theme named findandreplace.js and simply add the following line into that
jQuery("[href='/%3Cnolink%3E']").attr("href", "#");
so it simply replaces the nolink into # and it worked fine with special menu and nice menu.
May be this can help some one like me who needs simple solutions for the typical problems.
Comment #17
3rdLOF CreditAttribution: 3rdLOF commentedThis one to be inserted in current jQuery function.
$("a[href='/%3Cnolink%3E']").attr('href', '#');
I think yours is also missing the "a" selector:
jQuery("a[href='/%3Cnolink%3E']").attr("href", "#");
Comment #18
gagarine CreditAttribution: gagarine commentedOk apparently I will have to work on this one...
Comment #19
markwk CreditAttribution: markwk commentedI can confirm http://drupal.org/node/1221294#comment-5212154 fixes issue with superfish.
Comment #20
geek-merlinmy 5 cent here: this must be done in php, not js, to work in any case.
Comment #20.0
geek-merlinescaped <
Comment #21
geek-merlinhey, just looked and it seems to be already something in the dev source.
http://drupalcode.org/project/special_menu_items.git/blob/refs/heads/7.x...
i don't use this module right now but who is interested might try a
(don't forget angle brackets...)
i supose there will be still issues with it but it's clear from the source where to fix this.
Comment #22
patoshi CreditAttribution: patoshi commentedso the issue relies on lines 49 - 57 in the .module file... Currently there is no condition where it sets the nolink or seperator tags as chosen in the config page. I modified the return value:
http://img210.imageshack.us/img210/39/croppercapture90.jpg
by replacing the span with : a href="javascript:void(0)
since its temp fix for me. I didnt have time to make a patch and actually fix it. but all the pieces are there for anyone up for the task in making a patch for it... you'll just have to do a variable_get(...) to retreive the stored
Comment #23
DuaelFrHi !
Here is a two-in-one patch which :
- improves the usage of the "special_menu_items_nolink_tag" variable by including it in the "special_menu_items_link" function
- interfaces this module with core attributes system allowing to play with other modules like Menu Attributes
It applies well on the last dev version.
I hope you will enjoy it.
Regards.
PS : first point is related to comment #21
Comment #24
renard007 CreditAttribution: renard007 commentedFor good compatibility with all configuration of superfish & special menu items :
Use comment of Yaazkal (#12) & Yucom(#15)
Comment #25
gagarine CreditAttribution: gagarine commentedI commit the patch
#24#23 http://drupal.org/commitlog/commit/9840/a9dc66db0255b11b854572546e3a55e3... .Please try the 7.x-1.x-dev and see if it doesn't break anything ;).
Comment #26
netdreamer CreditAttribution: netdreamer commentedAfter trying dev version (that includes patch #1221294-23: option to use <a href="#"> for "nolink" items to not break other modules), I noticed that things were not working as expected, because a lot of informations/hooks were lost by manually creating the url.
So, I tried a specific approach for A links, so that they can use standard theming functions instead of recreating them.
The logic behind is that if the tag type is <a> (remember to set it in the configuration!) and the path is 'nolink', final destination should be an anchor.
BUT, url() function have some restrictions: valid path and valid anchor...
The url is now "same-path-as-this-page# ".
It works for me... does anyone have a better approach?
There was also a small validation error on PHP 5.2 due to ternary comparison operator short syntax, allowed only on PHP 5.3. I think that compatibility should be maintained if possibile as long as D7 still supports PHP 5.2, so I fixed the code.
Comment #27
gagarine CreditAttribution: gagarine commentedSorry I patch with #23 not 24... I will test that when I got some time (not this week). But I really want to push a new stable version next week. So thank for testing it this help a lot.
Comment #28
gagarine CreditAttribution: gagarine commentedThis had already be fixed. Patch need to be rerolled.
I want also to know witch module still break (so I can test) because now the class injection works better so some will perhaps works out of the box...
Comment #29
tchopshop CreditAttribution: tchopshop commentedTried patch from #26 and got an error.
Tried javascript above and it doesn't work because in my case because the nolink class appears on the li, not the a or the span.
Also, previously the a link was appearing above (not wrapping around) the ul submenu now the span is wrapping around the ul submenu.
I really need it to be a href="#" instead of a span...
Comment #30
gagarine CreditAttribution: gagarine commentedPatch 26 is in dev, just download the dev version. If you get an error.. write the error message in the comment please.
Comment #31
tchopshop CreditAttribution: tchopshop commentedI missed the module configuration page -- so I put in 'a' instead of 'span' and now it works. However the href="#" is not showing up, so it's an 'a' tag without an href, is that what's intended?
Comment #32
DuaelFrI use
<a href="javascript:void();">
in my configuration and it is working very well.Using an "a" tag without href attribute is not standard compliant, so certain old browsers could misinterpret it.
Comment #33
elBradford CreditAttribution: elBradford commented@DuaelFr
I used
<a href="javascript:void();">
and I get the following code spit out:In fact, any sort of attribute i put on the anchor tag is popped outside the anchor tag as its sibling. Maybe it's my superfish menus.
Comment #34
DuaelFrSorry I just seen there was another patch since mine.
I don't know what differs exactly but mine allowed and managed attributes like this.
Comment #35
netdreamer CreditAttribution: netdreamer commentedRerolled patch #26 to remove already fixed code.
I needed this patch to make menu_minipanels module work, because it required standard theming hooks to work...
Comment #36
netdreamer CreditAttribution: netdreamer commentedSorry, wrong call to the theme hook... patch #35 rerolled
UPDATE: Ignore this patch. Something wrong with CR/LF...
Comment #37
netdreamer CreditAttribution: netdreamer commentedRerolled... last time, hopefully!
Comment #38
khiminrm CreditAttribution: khiminrm commented#37 Works for me with Menu Minipanels module. Thanks for a patch!
Comment #39
gagarine CreditAttribution: gagarine commentedWe don't use theme_menu_link anymore #1447988: Override theme_link instead of the theme_menu_link.
Please open a new issue if it's still buggy.
Comment #40
netdreamer CreditAttribution: netdreamer commentedBug is still there, also on 2.x-dev, because "a" nolinks doesn't contain valid data for standard link rendering.
But, with the use of theme_link instead of theme_menu_link made in #1447988: Override theme_link instead of the theme_menu_link, patch was easy to made and it is also cleaner...
I also found a better way of creating the anchor link: by using url() "external" option, the null path problem with anchors explained in #1221294-37: option to use <a href="#"> for "nolink" items to not break other modules is solved.
Patch attached!
(I didn't open a separate issue, because it's exactly the same situation but handled with a different kind of patch...)
Comment #41
gagarine CreditAttribution: gagarine commentedin admin/config/system/special_menu_items you can now write
<a href="#">
for the nolink's tag and it will works. I don't want to encourage peoples without problem to create fake link. So I think this is a good enough solution.Comment #43
FrancoisL CreditAttribution: FrancoisL commentedHello
I try to make it work with Jquery Menu. I updated this module to be able to add
<a href="#">
for nolink elements and it work fine first. But I'm using Jquery Menu and it does not consider the "#" as a link. I don't know if I have to post this on this module sizde or on Jquery Menu side but looking at this thread perhaps someone experienced something that is working with JQuery Menu?Thanks in advance
Comment #44
FrancoisL CreditAttribution: FrancoisL commentedI finally closed this by using this resource: http://drupal.org/node/143322
Comment #44.0
FrancoisL CreditAttribution: FrancoisL commentedescaped <
Comment #45
kobb CreditAttribution: kobb commentedOr you could target the link with this selector:
a[href^="#"].some-class
or
li.some-class a[href^="#"]