Fix for Fix for Theme links - print descriptions of primary menu items

  1. <?php
  2.  
  3. /**
  4. * Return a themed set of links.
  5. * An override of theme_links()
  6. * Modified to use simple text styling instead of HTML & CSS
  7. *
  8. * @see theme_links
  9. */
  10. function phptemplate_links($links, $attributes = array('class' => 'links')) {
  11.   $output = '';
  12.  
  13.  
  14.   // Change the way primary links are rendered
  15.   if($attributes['class'] == 'links primary-links') {
  16.     $linklist = array();
  17.     $href = $link['href'] == "<front>" ? base_path() : base_path() . $link['href'];
  18.  
  19.     foreach ((array)$links as $key => $link) {
  20.         $linklist[] = '<a href="'. $href .'"><span class="menu-items"><h3>'. $link['title'].'</h3>'.$link['attributes']['title'].'</span></a>';
  21.     }
  22.     // Return the links joined by a '|' character
  23.     return join($linklist);
  24.   }
  25.  
  26.  
  27.  
  28.   if (count($links) > 0) {
  29.     $output = '<ol'. drupal_attributes($attributes) .'>';
  30.  
  31.     $num_links = count($links);
  32.     $i = 1;
  33.  
  34.     foreach ($links as $key => $link) {
  35.       $class = $key;
  36.  
  37.       // Add first, last and active classes to the list of links to help out themers.
  38.       if ($i == 1) {
  39.         $class .= ' first';
  40.       }
  41.       if ($i == $num_links) {
  42.         $class .= ' last';
  43.       }
  44.       if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
  45.         $class .= ' active';
  46.       }
  47.       $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
  48.  
  49.       if (isset($link['href'])) {
  50.         // Pass in $link as $options, they share the same keys.
  51.         $output .= l($link['title'], $link['href'], $link);
  52.       }
  53.       else if (!empty($link['title'])) {
  54.         // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
  55.         if (empty($link['html'])) {
  56.           $link['title'] = check_plain($link['title']);
  57.         }
  58.         $span_attributes = '';
  59.         if (isset($link['attributes'])) {
  60.           $span_attributes = drupal_attributes($link['attributes']);
  61.         }
  62.         $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
  63.       }
  64.  
  65.       $i++;
  66.       $output .= "</li>\n";
  67.     }
  68.  
  69.     $output .= '</ol>';
  70.   }
  71.  
  72.   return $output;
  73. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.