I'm slowly tearing out what little of my hair I have left trying to come up with a solution for this. If anyone is able to offer any advice I'd be really really grateful.

In a node view I'm filtering to a specific node type. Within that view I am displaying 'All Terms' of a specific vocabulary. This vocabulary is allowed to have multiple terms selected from it.

I'm wanting to show the individual Term Description of each of these Terms (I'm actually rewriting the output of 'All Terms' so that the term displays the description as a link to its term page). This works fine for nodes which only have one term selected, however when there are multiple terms selected only the first term's description is pulled through, and as such is used for each following term link.

I wondered whether the solution to this lays in theming, pulling in the term description for each term being displayed in the view. However I have had no luck finding the required variables to use.

I notice something relating to this being mentioned here http://drupal.org/node/345571#comment-1189361 Does that mean it's not possible?

I know everyone involved with views is very busy, so apologise if I'm being a nuisance with this query. But if anyone is able to point me in the right direction (or point blank tell me it can't be done) that would be fantastic.

Many thanks - Will

Comments

dawehner’s picture

Category: support » feature

This is a feature request. So it's not possible currently without a patch. You would have to write a own field_term_node_description handler which uses the pre_render method to load every description and display it with render_item

willhowlett’s picture

Many thanks. I'll have to roll up me sleeves and get my head round this api business then.

Cheers - Will

maikeru’s picture

Just found this issue when I was attempting the same thing. Thought I'd mention that I found it easier to add the description as a token rather then using render_item. You'll still need your own pre_render function to grab the description.

So I have something like this in my custom views handler:

  function document_self_tokens(&$tokens) {
    parent::document_self_tokens(&$tokens);
    $tokens['[' . $this->options['id'] . '-description' . ']'] = t('The term description.');
  }

  function add_self_tokens(&$tokens, $item) {
    parent::add_self_tokens(&$tokens, $item);
    $tokens['[' . $this->options['id'] . '-description' . ']'] = $item['description'];
  }

Then its available for use in the views UI where you can rewrite the output of the field.

Hopefully that helps people looking at the same thing.

OnkelTem’s picture

maikeru

Would you provide more of your code? Need the same thing, but I've never dealt with custom views handlers and afraid have no time atm to learn this subject from scratch :(

Thanks in advance

Letharion’s picture

Status: Active » Fixed
Letharion’s picture

Assigned: Unassigned » merlinofchaos
Status: Fixed » Active

Sorry, feature request, not support.

@Merlinofchaos
Task, or not?

merlinofchaos’s picture

Version: 6.x-2.8 » 6.x-3.x-dev
Assigned: merlinofchaos » Unassigned
Category: feature » task

Unassigned task. A patch of the above code totally makes sense and would be considered for 3.x

willhowlett’s picture

Came back to this after literally ages. Just as an update found a very simple way of achieving this through the theme layer if that's of use to anyone reading this.

I used something like this in a nid field tpl. Not as nice as doing it properly with the methods detailed above, but quick and easy.

<?php
$node = node_load($row->nid);
$tids = taxonomy_node_get_terms_by_vocabulary($node, 1);
?>
<ul>
<?php foreach ($tids as $term) : ?>
	<li><a title="<?php print $term->description;?>" href="/<?php print taxonomy_term_path($term);?>"><?php print $term->description;?></a></li>
<?php endforeach;?>
</ul>
couturier’s picture

Status: Active » Closed (won't fix)

Most people are working in Drupal 7 and Drupal 8 now. When D8 is released in less than a year, support for D6 will be dropped.