Support for views and d display suite

Comments

wouters_f’s picture

*comment because original post could not be edited.

I had to add this code to my template file to make the image_alter work in views.
When I used the normal term and term_image fields,not all the terms were replaced by image.
The replacing only occurred for terms that were loaded with a node that was loaded on the page.

The support for image_alter is lacking.


$preset = variable_get('taxonomy_image_link_preset', variable_get('taxonomy_image_imagecache_preset', 'ORIGINAL'));
    $taxo_image = taxonomy_image_display($row->tid, NULL, $preset, array('wrapper' => FALSE));
    print l($taxo_image, taxonomy_term_path($row),array('html'=>true));

I also had to change some coding in display suite to make my build modes and term image_replacing work well.
The coding can be found below:

function nd_terms_per_vocabulary($field) {
  $content = '';
  if (isset($field['object']->taxonomy) && !empty($field['object']->taxonomy)) {

    $terms = array();
    $linked = FALSE;
    $vid = end(explode('_', $field['key']));
    $formatter_explode = explode('_', $field['formatter']);
    $separators = array('space' => ' ', 'comma' => ', ');
    $separator = $separators[end($formatter_explode)];
    $linked = prev($formatter_explode);
    $preset = variable_get('taxonomy_image_link_preset', variable_get('taxonomy_image_imagecache_preset', 'ORIGINAL'));
    foreach ($field['object']->taxonomy as $tid => $term) {
      if ($term->vid == $vid) {
        $taxo_image = taxonomy_image_display($tid, NULL, $preset, array('wrapper' => FALSE));
          if ($taxo_image) {
         }else{
          $taxo_image = $term->name;
      }
       $terms[] = ($linked == 'linked') ? l($taxo_image, taxonomy_term_path($term),array('html'=>true)) : check_plain($term->name);
      }
    }
    if (!empty($terms)) {
      $content = implode($separator, $terms);
    }
  }
  return $content;
}

Please make some hooks or include views support for this module. I'm using it because it's great.

artis’s picture

Where specifically did you place the code above that allows image_alter to work with views?

Thanks.

jddeli’s picture

Please tell how do you fix it?

wouters_f’s picture

I fixed it at that time by changing some code in the node display module. (function nd_terms_per_vocabulary)
This is not very clean as it should be solved in the taxonomy image module.
That's why I posted the issue here.
My experience with this taxonomy image module (and more specific the compatibility) is not very great, and I discourage using this module.
In D7 terms will be fieldable so that won't be a problem anymore.