I'm trying to modify the code for the main menu only. below is my sorry code, which is not working. it attempts to see if $variables['heading']['text'] equal 'Main menu'

function myTheme_link($variables) {
if($variables['heading']['text'] == 'Main menu') {
//put my mods here
} else {
  return '<a href="' . check_plain(url($variables['path'],     $variables['options'])) . '"' . drupal_attributes($variables['options']    ['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] :     check_plain($variables['text'])) . '</a>';

this must be close, no? i would greatly appreciate if someone could advise

  • i'd like to elaborate further. what the client wants are evenly spaced bullets between menu items. like so, Link1 * Link2 * Link3 * Link4. perhaps there is a better than using theme_link.??
    – TopTomato
    Aug 19, 2014 at 21:27

2 Answers 2


How about a pure CSS solution:

#block-system-main-menu ul li:after {
#block-system-main-menu ul li.last:after {

Or something to that effect.

To get support for IE7 look here.

  • it works, pretty cool!
    – TopTomato
    Aug 21, 2014 at 23:54

You can do it by using this code in template.php file of your active theme.

function mytheme_links__system_main_menu($variables) {
  $html = "<div class='myclass'>";
  $html .= "  <ul>";  
  foreach ($variables['links'] as $link) {
    $html .= "<li>".l($link['title'], $link['path'], $link)."</li>";
  $html .= "  </ul>";
  $html .= "</div>";

  return $html;

or you can add customization in $variables also if we have do minor customization to do. Here replace mytheme with name of your theme. Clear you cache after using this code.

Hope it will help you!

  • thanks, that looks like exactly what i need but the function isn't firing now matter what. yes i replaced mytheme with spn_at and also cleared the cache everytime after adding or renaming this func. i've added the kpr($variables) to look at vars and also verify the func is running but it is not. hmmmmm......???
    – TopTomato
    Aug 21, 2014 at 23:35
  • maybe i need to clear the theme registry?
    – TopTomato
    Aug 21, 2014 at 23:43
  • i'm using a sub theme of the adaptive theme. maybe that's not helping ..?
    – TopTomato
    Aug 21, 2014 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.