Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cossme’s picture

have the same problem
Nice Menus 6.x-2.1
Menu Attributes 6.x-2.0-beta1

jtwalters’s picture

I have the same problem...

jvandooren’s picture

Version: 6.x-2.x-dev » 7.x-2.0-beta2

Hello

I have the same problem with the 7.x-2.0-beta2 version. I want the menu_attribute class on the "li" and not on the "a" tag, so I did the following (in nice_menu.module, around line 447):

<?php
if ($trail && in_array($mlid, $trail)) {
  $class .= ' active-trail';
}
// -- Begin change
if (isset($menu_item['link']['options']['attributes']['class'])) {
  $class .= ' ' . $menu_item['link']['options']['attributes']['class'];
}
// -- End change
// If it has children build a nice little tree under it.
?>

You can also do something like this (starting in nice_menus.module line 450) (look for the capital case comments :)):

<?php
      // --> ADDED THIS
      if (isset($menu_item['link']['options'])) {
        $options = $menu_item['link']['options'];
      }
      // --> END

      // If it has children build a nice little tree under it.
      if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below'])) && $depth != 0) {
        // Keep passing children into the function 'til we get them all.
        $children = theme('nice_menus_build', array('menu' => $menu_item['below'], 'depth' => $depth, 'trail' => $trail));
        // Set the class to parent only of children are displayed.
        $parent_class = ($children && ($menu_item['link']['depth'] <= $depth || $depth == -1)) ? 'menuparent ' : '';
         
         $element = array(
          '#below' => '',
          '#title' => $menu_item['link']['link_title'],
          '#href' =>  $menu_item['link']['href'],
          '#localized_options' => $options, // --> CHANGED THIS
          '#attributes' => array(),
        );
        $variables['element'] = $element;
        
        $output .= '<li class="menu-' . $mlid . ' ' . $parent_class . $class . $first_class . $oddeven_class . $last_class . '">'. theme('nice_menus_menu_item_link', $variables);
        // Check our depth parameters.
        if ($menu_item['link']['depth'] <= $depth || $depth == -1) {
          // Build the child UL only if children are displayed for the user.
          if ($children) {
            $output .= '<ul>';
            $output .= $children;
            $output .= "</ul>\n";
          }
        }
        $output .= "</li>\n";
      }
      else {
     
        $element = array(
          '#below' => '',
          '#title' => $menu_item['link']['link_title'],
          '#href' =>  $menu_item['link']['href'],
          '#localized_options' => $options,  // --> CHANGED THIS
          '#attributes' => array(),
        );
        $variables['element'] = $element;
        $output .= '<li class="menu-' . $mlid . ' ' . $class . $first_class . $oddeven_class . $last_class . '">' . theme('nice_menus_menu_item_link', $variables) . "</li>\n";
      }
?>

This will put the class on the "a" instead of the "li".

Maybe this is not the way to do it, but it helped me out for now :)

Oz

jtwalters’s picture

Status: Reviewed & tested by the community » Active
FileSize
629 bytes

** See #6 **
This one liner patch fixes the D7 version incompatibility with menu_attributes module (for me). Any classes that I set are now applied to the links.

gapa’s picture

On a quick look this patch is working for me.

tnx

joelstein’s picture

Status: Active » Needs review
FileSize
772 bytes

The patch in #4 missed one spot. Here's a revised version.

WillHall’s picture

The patch at #6 is exactly what I needed to get special_menu_items and my own stack altering modules working.

Thanks!

BWPanda’s picture

Status: Needs review » Reviewed & tested by the community

I needed to access the link's descriptions and the patch in #6 made them available for me.

amateescu’s picture

Version: 7.x-2.0-beta2 » 7.x-2.x-dev
Status: Active » Reviewed & tested by the community
FileSize
1.28 KB

Re-rolled as a proper git patch, with credit to @jtwalters and @joelstein.

Still RTBC.

tom friedhof’s picture

Re-rolled the patch again from #9 with --no-prefix.

drush_make didn't like the format of the patch from #9. This patch will work with drush_make.

laroccadahouse’s picture

worked for me. thanks!

vordude’s picture

Status: Reviewed & tested by the community » Fixed

committed with 624d25cc7f01f

Status: Fixed » Closed (fixed)

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

emcniece’s picture

um...

Did the D6 version ever get a patch?

designguru’s picture

I'm looking for a Drupal 6 solution too - anyone fix it???

q./