1

I have one vocabulary with two terms, apples and oranges. Nodes are tagged with either one or the other. I created a view at /fruits that shows the nodes tagged with either term. I also have the field settings set to Group by Taxonomy term which works great.

It places the taxonomy term heading at the top of each section. Now on to my question... Is it possible to display the term description under each taxonomy heading? So it would look like below.


Oranges (Taxonomy Title)

Oranges are probably the best fruit on earth. (Term Description)

(Results of view)

1
  • Where you've put '(Results of view)' in your question, what is it that you want to see there? Can you clarify? If it's node information, e.g. a list of titles or a count of nodes falling under the taxonomy, then the answer as @Aiias will work, but the View will need to be set up to Show Content rather than (as Aiias's answer might suggest) Show Taxonomy. And you will then need to add your taxonomy field as a relationship. Once it's added as a relationship, then the taxonomy's Description field (and, indeed any other field) will be available.
    – Obliquely
    Mar 10, 2013 at 18:26

3 Answers 3

5
+50

One option for solving this is to rewrite the output of your view fields to meet your formatting requirements, which consists solely of configuration steps -- no code changes needed :).

  • On your view, add the Taxonomy: Term field and the Taxonomy: Term description field. Make sure the Term field is above the Term description field.

  • Next, edit the Term field, select Exclude from display, and click Update.

  • Now, edit the Term description field and check Rewrite the output of this field. You can set this Term description field to include the formatting you desire of your Term name and Term description using the available tokens, which are listed in the Replacement patterns fieldset.

For example, try placing the following into the rewrite Text textarea:

<h1>[name]</h1>
<p>[description]</p>

Be sure to click Update after you have finished configuring the Term description field.

  • Last, in your field settings, select Group by Term description and voilà, you should have all the data you want in each grouping section. As long as your term names or term descriptions are unique, this should group as expected.
0

A simple way is to insert a Term-id field also in your view and rewrite results with PHP in order to load the term from the tid and get its description like

$term = taxonomy_get_term($tid, $reset = FALSE);
echo $term->description;

if i remember Drupal 6 correctly anyway ..

0

Drupal 7 may require the use of relationships. At first I was confused about the missing Taxonomy: Term description in my view but then I read this in the Views docs.

Drupal 7 made significant changes to Taxonomy. Because of this, many taxonomy functions Views can perform are now part of relationships. If you can't find the filter you need, add either the related taxonomy terms relationship, or a relationship on the specific taxonomy field.

Also this comment was very useful for me. https://drupal.org/node/258287#comment-6144566

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.