Project:Menu Class
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

Hi,
I am able to add classes to some menu items and not others.

Specifically, I am able to add classes to "navigation" menu items, but not to "primary link" menu items.

To help diagnose the problem I ran a test and it seems that "navigation" menu item links are getting passed to the function phptemplate_menu_item_link($link), but "primary" menu items links are not.

In case it is relevant, I am creating the primary-link menu during installation. Here is the code from my install profile that creates the primary-link menu:

$primary_links = array (
    array(
      'menu' => 'primary-links',
  'title' => 'Home',
  'path' => '<front>',
  'weight' => 1,
),
array(
      'menu' => 'primary-links',
  'title' => 'About Us',
  'path' => 'about',
  'weight' => 2,
),
  );

  foreach ($primary_links as $item) {
    install_menu_create_menu_item($item['path'], $item['title'], '', $item['menu'], 0, $item['weight']);
  }

Any thoughts about what may be happening?

Thanks very much,
Mindy

Comments

#1

I have the same issue. I can't add classes to the "Primary Links" menu, or to a custom menu I have created. Hope this gets fixed.

#2

Same here. Unfortunately, without this, I can't use it.

#3

Add the following code to theme template.php.

function phptemplate_links($links, $attributes = array('class' => 'links')) {
  if (function_exists('menuclass_to_link')) {
    foreach ($links as $key => $item) {
      if (preg_match('/^menu-(\d+)/', $key, $matches)) {
        $link = array(
          'mlid' => $matches[1],
        );
        $link['localized_options']['attributes'] = $item['attributes'];
        menuclass_to_link($link);
        $links[$key]['attributes'] = $link['localized_options']['attributes'];
      }
    }
  }
  return theme_links($links, $attributes);
}

#4

I am having the same issue. I added the above code to template.php and it did not help. No classes are added to Primary Links.

#5

Status:active» needs work

Same here, the code for template.php didn't work. Is there anything new on this? I would like to use this module on my site..

#6

Status:needs work» active

I got something. I don't know if anyone here read the readme.txt from the module.
It says that you have to copy some code to your template.php file to get menu_class to work.

I can add classes to my primary links after I copied the code.
So I just want to say RTFM to myself :-D

#7

Status:active» closed (won't fix)

This module is now obsolete. Please see the module's project page.

nobody click here