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 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
Comment #1
banjer CreditAttribution: banjer commentedI 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.
Comment #2
couloir007 CreditAttribution: couloir007 commentedSame here. Unfortunately, without this, I can't use it.
Comment #3
masakura CreditAttribution: masakura commentedAdd the following code to theme template.php.
Comment #4
buttonwillowsix CreditAttribution: buttonwillowsix commentedI 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.
Comment #5
lloyyd CreditAttribution: lloyyd commentedSame 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..
Comment #6
lloyyd CreditAttribution: lloyyd commentedI 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
Comment #7
daniboy CreditAttribution: daniboy commentedThis module is now obsolete. Please see the module's project page.