Hi,

I'm using hook_menu_link_alter() to add CSS classes to menu items and links during installation (custom installation profile). The installation goes well, without errors and the classes are added correctly to menu items and links.

When I go to the link edit page (e.g. admin/structure/menu/item/1/edit) my class is displayed correctly in the class form of Menu Attributes, but when I save Menu Attributes prints twice the defined CSS class. If I re-visit the page I see the class duplicated in the class form of Menu Attributes, and if I re-save the CSS class is tripled.

With the classes added to menu items - instead of menu links - there are no problems.

I know I'm not very good at English, please be patient. :)

Comments

O U T L A W created an issue. See original summary.

wafer’s picture

Assigned: Unassigned » wafer

Assigning this issue to myself,will let you know if I could solve until you can use in this way,it's easy same as you done.

function MYTHEME_preprocess_html(&$vars) {
    // Add font awesome cdn.
  drupal_add_css('//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css', array(
      'type' => 'external'
    ));
}

Or else you can instantiate font lib using theme info.

MYTHEME is your theme name.Don't forget to clear the cache.
Then go to your each menu links,under the MENU LINK ATTRIBUTES section you will find class option and then add font icons class like fa fa-home,fa fa-dashboard etc.

I hope you get helped.

joelpittet’s picture

Status: Active » Fixed

Don't think this has to do with menu_attributes, but #2 looks like you are on the wright track with a better way to attach external CSS assets.

O U T L A W’s picture

I think I was using hook_menu_link_alter() improperly. Every time I edit a link my hook_menu_link_alter() is called, adding the class which I told to add. That's why my class was duplicated. Please tell me if it's not so.

What I was attempting to do was editing the links attributes during Drupal installation, so i don't have to edit the link attributes every time. I've not found a way to edit the link attributes into an installation profile.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.