By jive01 on
following code in my template.php file:
<?php
function THEMENAME_link($variables) {
return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '><span>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</span></a>';
}
?>
However, this wraps span tag around EVERY menu item.... I would like to just specifically do this to my main menu (primary links).
Doing this
<?php function THEMENAME_links__system_main_menu($variables) ?> Results in a big fat error....
So any ideas on how to use the above code to specifically change the main menu would be fantastical help. ;)
Comments
big fat error :D
You may have been close to the solution.
I've tried on template.php this code:
... and I don't have any errors from it. (remember to clear cache)
I hope this can be a good start point
Cheers
Thank you very much
Hi francort - this worked GREAT for me. Thank you so much; I've been unable to find a solution for a couple of days now.
theme_link and theme_links
theme_link and theme_links are both different functions.
xxx_link__main_menu() or xxx_link__main_menu__system_main_menu() doesnt seem to work.
it however works for theme_links!
A simple solution
francort's solution seems a bit much. After much trial and error, I came up with this:
I found the solution to this
I found the solution to this problem after a lot of searching. By the way this works to customize the output of the links of any specific menu.
Let me just say first that customizing the primary or main menu links is something essential to any theming, and the only reason I can think of why Drupal programmers made it so hard to do is so that professional Drupal themers can keep their jobs!
I saw solutions using the theme_link function : bad idea because this will alter the output of ALL your links, which will break your site's layout.
So my approach is to you override the theme_menu_link function. I add a condition to use the override only on the specific menu I want. In this example I chose the primary links. To know the name of the menu you want to theme you have to put dsm($variables) and usse the Devel module.
If anyone knows of a more simple way let me know. I'm no expert just pieced together this solution after a lot of trial and error.
For changing the primary menu links in Drupal 7
Article taken from http://www.webmediahutch.com/customizing-primary-menu-links-drupal-7