I am trying to replace certain taxonomy terms with icon for an Intranet I am building. I have taken code from http://drupal.org/node/149738 and placed it in template.php. This works fine. The code snippet to display an icon is below. This looks for the a class that contains both 'links' and 'inline'

 function phptemplate_links($links, $attributes = array('class' => 'links')) {
  // configuration for this function:
  $replacements = array();
  
  // create a new element in array $replacements for each taxonomy term that will be replaced by
  // an image (only when it's in a class containing 'inline' and 'links', such as the $terms list.
  // In the replacements array, add any attributes you want in the <img> tag, such as 'src' and 'alt'
  
 if (page == 0) :
  // Urgent
  $replacements['taxonomy_term_1'] = array(
    'src' =>  '/themes/danger4k/icons/flag_red.png',
    'alt' =>  'Urgent Notices',
    'id'  =>  'urgent-notices',
    'width' =>  '16',
    'height'  =>  '16',
    'class' =>  'taxonomy_image',
    );
  // Essential
  $replacements['taxonomy_term_2'] = array(
    'src' =>  '/themes/danger4k/icons/flag_yellow.png',
    'alt' =>  'Essential Reading',
    'id'  =>  'essential-reading',
    'width' =>  '16',
    'height'  =>  '16',
    'class' =>  'taxonomy_image',
    );
  // Other
  $replacements['taxonomy_term_3'] = array(
    'src' =>  '/themes/danger4k/icons/flag_green.png',
    'alt' =>  'Other News',
    'id'  =>  'other-news',
    'width' =>  '16',
    'height'  =>  '16',
    'class' =>  'taxonomy_image',
    );
 endif;
  // modify the links if class contains both 'links' and 'inline'
  // because these might be linked taxonomy terms
  if (strstr($attributes['class'], 'links') && strstr($attributes['class'], 'inline')) {
    foreach ($links as $key => $link) {
      if (array_key_exists($key, $replacements)) {
        // create image html code and then pass that as the content instead
        // of the title so that the image will be a link        
        $img_tag = '<img ';
        foreach ($replacements[$key] as $img_key => $img_attr_value) {
          $img_tag .= $img_key. '= "' .$img_attr_value. '" ';
        }
        $img_tag .= '/>';
        $links[$key]['title'] = $img_tag;
        $links[$key]['html'] = TRUE;
      }
    }
  }
  return theme_links($links, $attributes);  
}

I have since created a view using the views module to display as a table, but the taxonomy term shows as text, so I added the following code snippet to the function in template.php just before the return theme_links($links, $attributes); statement but it does not change the view. This looks for a class that contains 'view-field' and 'view-field-term-data-name' and is supposed change that term to an icon.

/* Same for Views Data */
  if (strstr($attributes['class'], 'view-field') && strstr($attributes['class'], 'view-field-term-data-name')) {
    foreach ($links as $key => $link) {
      if (array_key_exists($key, $replacements)) {
        // create image html code and then pass that as the content instead
        // of the title so that the image will be a link        
        $img_tag = '<img ';
        foreach ($replacements[$key] as $img_key => $img_attr_value) {
          $img_tag .= $img_key. '= "' .$img_attr_value. '" ';
        }
        $img_tag .= '/>';
        $links[$key]['title'] = $img_tag;
        $links[$key]['html'] = TRUE;
      }
    }
  }

This has been baffling me for a view weeks now and I am unsure as where to turn next.

I would really appreciate some help with this

Thanks