I'm new to Drupal and am trying to make a sub theme of zen. I try to theme the primary links.

Everywhere I look it says I should override theme_links(), but when I check with the theme devel module it says I should use themename_menu_item_link() to override the primary links.

When I try with other themes the devel module says the theme_link() is used.

I tried to override the theme_link() in my theme and only the "read more" link under the content in node.tpl.php, written by

<?php print $links; ?>

is affected.

The primary links written by

<?php print theme('links', $primary_links); ?>

is unaffected

Am I totally lost or does anybody know what this means

Thanks
kritro

Comments

mistresskim’s picture

Have you tried copying (and renaming) the zen_menu_item_link($link) function (in zen/template-menus.php) into your SUBTHEMENAME/template.php file? Something like this...


function SUBTHEMENAME_menu_item_link($link) {
  if (empty($link['options'])) {
    $link['options'] = array();
  }

  // If an item is a LOCAL TASK, render it as a tab
  if ($link['type'] & MENU_IS_LOCAL_TASK) {
    $link['title'] = '<span class="tab">' . check_plain($link['title']) . '</span>';
    $link['options']['html'] = TRUE;
  }

  if (empty($link['type'])) {
    $true = TRUE;
  }
  
  // Do special stuff for PRIMARY LINKS here
  if ($link['menu_name'] == 'primary-links') {
   // print_r($link);
   // do stuff here
  }

  return l($link['title'], $link['href'], $link['options']);
}
 
kritro’s picture

Thanks
That seems right.

When i print it out, my two primary links is showed

<?php
 // Do special stuff for PRIMARY LINKS here
  if ($link['menu_name'] == 'primary-links') {
   print $link['title'];
   // do stuff here
  }
?>

Is this the place to add theming to the links? If I for inst. want to add a ">>" beetween the links, is this the place to do it by updating the $link array?

Is this not swinging by theme_links() method at all?
I can see it calls the l() method and it seems this is where the href tag is added

<?php
return '<a href="'. check_url(url($path, $options)) .'"'. drupal_attributes($options['attributes']) .'>'. ($options['html'] ? $text : check_plain($text)) .'</a>';
?>

I mostly try to understand the consecpt here.

Thanks kritro

mistresskim’s picture

Anything you do in the above function will modify the primary links outputted via the Primary Links block. So doing a $link['title'] .= '>>' there will alter your links.

However, there is also another Primary Links menu (which you can activate from admin/build/themes/settings/THEMENAME), and I think that one uses the theme_links() function instead. I'm not sure why there are two. I guess the former is the product of the Zen theme and the latter is the native Drupal one.

leofishman’s picture

I am using zen 6.x-1.1 but I can't find template-menu.php

how can I customize the menu?

thanks,

Leo