Template.php not overriding function

DoctorOak - November 8, 2009 - 02:25

Hi,

I'm trying to theme the Taxonomy pages to be, well, not useless - and it's been a pain in the ass getting to where I am already with it - but now I'm being held back further by issues with the system surrounding template.php function replacement.

I'm trying to override the "theme_taxonomy_term_page" theme, and have tried replacing the 'theme' part with both phptemplate and my theme name to no avail either way. The function just doesn't run.

If I edit the original function in taxonomy.pages.inc, then the changes show, but no matter what I do, I can't get template.php's version of the function to override it.

The template.php page is in the correct place, and by testing code outside of any functions I can confirm that it's being called successfully on the intended pages - but the function is not.

Here's the function as it is in template.php (using phptemplate instead of the theme name in this instance):

function phptemplate_taxonomy_term_page($tids, $result) {
  drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css');


  $output = '';

  // Only display the description if we have a single term, to avoid clutter and confusion.
  if (count($tids) == 1) {

    $term = taxonomy_get_term($tids[0]);

    if ($children = taxonomy_get_children($tids[0])) {
      $output .= '<div class="subterms">';
      // $items = theme('directory_list_subterms', $children);
      foreach ($children as $child) {
        $items[] = l($child->name, "taxonomy/term/$child->tid");      }
      $title = t('Children of !term', array('!term' => $term->name));
      $output .= $title .': '. implode(', ', $items);
      $output .= '</div>';
    }

    $description = $term->description;

    // Check that a description is set.
    if (!empty($description)) {
      $output .= '<div class="taxonomy-term-description">';
      $output .= filter_xss_admin($description);
      $output .= '</div>';
    }
  }

  $output .= taxonomy_render_nodes($result);

  return $output;
}

Now, I know the function changes themselves work - because they work on the original function. But how, exactly, do I get template.php to override it so I can keep to best practices?

...

Jeff Burnz - November 8, 2009 - 05:25

Clear the theme registry, likely the new override is not being picked up until you do this.

Hooray - finally got it to

DoctorOak - November 8, 2009 - 12:55

Hooray - finally got it to work.

Thanks. :)

 
 

Drupal is a registered trademark of Dries Buytaert.