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.
Hi,
I've set id and class on menu-items using Menu attributes module, and it seems like Superfish overwrites any attributes set by this module. This was not the case with previous version 1.8-alpha version of Superfish.
Comments
Comment #1
mehrpadin CreditAttribution: mehrpadin commentedFixed as of version 1.8 :)
Comment #2
mehrpadin CreditAttribution: mehrpadin commentedComment #3
dhatman CreditAttribution: dhatman commentedGreat Mehrpadin! Many cudos.
Comment #5
h3rj4n CreditAttribution: h3rj4n commentedThis issue is still there.
I tried to set the target of the link, didn't work. After reading this thread I tried to add a class, didn't work either.
Comment #6
mehrpadin CreditAttribution: mehrpadin commentedHoi,
Use the v1.9-beta4 please :)
Comment #7
h3rj4n CreditAttribution: h3rj4n commentedStill doesn't work.
I think the problem doesnt lay in this module. To populate the menu the function menu_tree_all_data is called. This function doesn't return the menu with attributes. I tried to trace back where the attribute value get's emptied but couldn't find it.
Comment #8
mehrpadin CreditAttribution: mehrpadin commentedCan someone try the development version please?
Comment #9
Amir Simantov CreditAttribution: Amir Simantov commentedI second h3rj4n in #7 - does not work even in v1.9-beta5.
Comment #10
Michael Dajewski CreditAttribution: Michael Dajewski commentedDrupal core ver.: 7.22
Menu attributes: 7.x-1.0-rc2
Superfish: 7.x-1.9
Steps to duplicate:
1. For one of Main menu items select 'New window (_blank)' in 'Menu item attributes' section, which will add target attribute to the link.
2. Resize the browser window to to trigger smallscreen.js (may need for that responsive theme).
The menu html is changer from
to
...
e.g.:
<a href="url" target="_blank" class="sf-depth-1">Menu item</a>
will get translated to:
<option value="url">Menu item</option>
The target attribute from the link is missing in the option, therefore the link opens in the same window/tab.
From little research I had time to do, in order to achieve opening new window/tab...
Instead of using window.location property it would be better to use the window.open() method.
See: sfsmallscreen.js and perhaps sftouchscreen.js.
As for storing target attribute inside one could use either class (global attribute).
Could someone wake-up and give it a thought, this bug has been filed over two years ago!!!
PS
While using
<option>
instead of<a>
one should remember to somehow store following atributes that are valid for<a>
:Title
ID
Name
Relationship
Classes
Style
Target
Access Key
Comment #11
4fs CreditAttribution: 4fs commentedJust to my 2 cents.
I removed menu attributes and just used default description and this issue is still occurring, so nothing to do with menu attributes. This is rather a big deal as I am using the attributes for describing my links. The links are useless without a description. I have tested latest dev and v1.9 and both do the same. Thanks.
Comment #12
4fs CreditAttribution: 4fs commentedAny help would be appreciated here. :) I am having to manually update the title every day for the site I am using this feature. Thank you.
Comment #13
mehrpadin CreditAttribution: mehrpadin commentedHey everybody,
Apologies for the late reply, terribly busy, I just read all the comments here again, looks like you are all talking about different issues!
filter_xss
that is unfortunately removingstyle=""
attributes and some others (there's an issue for) but indeed nottarget=""
, etc.Comment #14
mehrpadin CreditAttribution: mehrpadin commentedComment #16
NaX CreditAttribution: NaX commentedI solved this problem in my theme by adding the following to my template.php. Maybe this should be documented as a possible method of integration with other menu modules, like menu attributes.
This code is not perfect, I have not looked at each possible attribute for differences in how it should be merged. A space has been assumed for all.
item
Comment #17
ron_s CreditAttribution: ron_s commentedI'm using Superfish 7.x-1.9+33-dev and Menu Attributes 7.x-1.0-rc3. Menu attributes work correctly for menu links, but not for menu items. To replicate:
If the same steps are taken and the Menu Link Attributes are modified, it works, but not the Menu Item Attributes.
Comment #18
vaccinemedia CreditAttribution: vaccinemedia commentedI can confirm what @ron_s says - menu link attributes are being applied but menu item attributes are not when using the menu attributes module.
Comment #19
gmora2 CreditAttribution: gmora2 commentedCan confirm I am having the same issue with superfish overriding the item attribute from Menu Attribute module. Does anyone have a fix?
As a temporary fix, you are able to use JQuery to add a class to the list element in reference to targeting the anchor element.
Comment #20
jastraat CreditAttribution: jastraat at Technivant commentedSadly the code in 16 did not work for us. Even when a menu item had a class defined, $variables['element']['item']['link']['options']['attributes'] was empty, and the menu item class was nowhere in the item array.
(As others have mentioned, menu link classes work without a problem.)
Comment #21
jastraat CreditAttribution: jastraat at Technivant commentedIt looks like the menu item attributes are stored in $variables['element']['item']['link']['options']['item_attributes']
Comment #22
Geijutsuka CreditAttribution: Geijutsuka commentedConfirmed that the menu list item classes are being overridden. As a temporary fix we are also using jQuery to add the needed class to menu items.
Comment #23
5n00py CreditAttribution: 5n00py commentedConfirm, menu item attributes not working.
Comment #24
jeremypeter CreditAttribution: jeremypeter commentedI was having this issue with both Superfish v1.9 and Superfish v2.0, using Special Menu Items v7.x-2.0. So I was able to resolve this by using a preprocess function to modify the attributes array of the theme_superfish_menu_item() function. It will override the ID of the menu list item if provided, add classes to the existing Superfish classes and add the style attribute if values are provided.
Comment #25
Mykhailo.Levchenko CreditAttribution: Mykhailo.Levchenko commentedThat's work! Thanks!
Comment #26
lubwn CreditAttribution: lubwn commentedI can confirm #24 works! Thanks a lot!
Comment #27
banoodle CreditAttribution: banoodle at Kanopi Studios commented#24 worked for me too (thank you!), but for anyone else who might try this, I did need to change the line that reads...
if(isset($item_options['item_attributes'])){
to
if(isset($item_options['attributes'])){
Comment #28
ivnish CreditAttribution: ivnish commented