Trouble getting theme functions overridden

stoeckler - November 28, 2007 - 16:30

Hey there,

i've already tried a bunch of stuff to get it working, including looking into the core's garland's template.php for guidance and browsing through the Drupal 6 API-documentation.

My problem is: i would like to customize the way Drupal 6 outputs the attachments of a given node. I've changed the theme_upload_attachments function to my liking, put it in my theme's template.php - just as i was used to for Drupal 5 - but it doesn't change a thing. Am I missing something? I feel like i haven't fully grasped the potentially new concept of overriding functions in Drupal 6, despite reading the "Converting 5.x themes to 6.x" / http://drupal.org/node/132442 and "Overriding theme functions" / http://drupal.org/node/173880 pages in the handbook. So now I'm hoping one of you can help me get this working.

As reference, my template.php containing only the customized function is as follows:

<?php

function phptemplate_upload_attachments($files) {
   
$header = '<div id="attachment_header"><div id="attachment_file">' . t('Attachment') . '</div><div id="attachment_size">' . t('Size') . '</div></div>';
   
$content = '<div id="attachment">' . $header;
   
$i = 0;
    foreach (
$files as $file) {
       
$file = (object)$file;
        if (
$file->list && empty($file->remove)) {
           
$href = file_create_url($file->filepath);
           
$text = $file->description ? $file->description : $file->filename;
           
$link = l($text, $href);
           
$size = format_size($file->filesize);
           
$content .= '<div class="attachment_file"><div class="attachment_link">' . $link . '</div><div class="attachment_size">' . $size . '</div></div>';
           
$i++;
        }
    }
   
$content .= '</div>';
    if (
$i > 0) {
        return
$content;
    }
}

?>

Thank's a lot for any help!

Theme registry

jwolf - November 28, 2007 - 18:13

Any chance you may be missing this part:

"Theme registry"
http://drupal.org/node/132442#theme-registry

Important note! Whenever a you add a new theme function or template inside your theme the registry must be cleared!

It works!

stoeckler - November 28, 2007 - 18:56

Thank you very very much! I promise to next time read even more thoroughly! You guys make an awesome community!

 
 

Drupal is a registered trademark of Dries Buytaert.