I'm having some trouble trying to get a tax. term description to show in Views.

I have a page View with an exposed filter of taxonomy terms. The page layout is like this:

Page Header
---------------
Exposed taxonomy filter drop down | Select button

Tax term description box
--------------
Relevant node to tax selected
Relevant node to tax selected
Relevant node to tax selected
Relevant node to tax selected
Relevant node to tax selected

I have the header defined within the View itself as is the exposed filter, but the tax term description box is themed in template.php and the displayed nodes are also themed in template.php in a foreach loop.

I need the selected taxonomy term's description to show up in the description box. I have tried to use version 1 of the Taxonomy Context module, but that didn't seem to work.

Any insight in to this would be helpful - although a solution would be greatly appreciated (obviously).

Thanks

Comments

jasom’s picture

same problem:

taxonomy views with term destription in header? how? :}

acdtrp’s picture

same question for me.

chrisyates’s picture

(at least with D6, have not tried with D5 or earlier)

<?php
$view = views_get_current_view();
if (is_numeric($view->args[0])){
  $term = taxonomy_get_term($view->args[0]);
  return $term->description;
}
?>

-c

netentropy’s picture

is there anyway to have this show only on the first page of the list and not on the paginated pages

irwin nerwin’s picture

FTR, chrisyates' code worked for me in a D7 Views header by simply substituting taxonomy_term_load for taxonomy_get_term

https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/funct...

giorgosk’s picture

This also works with php code in header

$current = taxonomy_get_term(arg(2));
echo $current->description;

------
GiorgosK
Web Development

mittalpatel’s picture

To get the taxonomy description in views in Drupal 7 you can follow this:

  • Add a relationship "Content: Taxonomy terms on node".
  • Select the Vocabularies you want to add in relationship.
  • Now, go to field adding and you can select "Taxonomy term: Term description" and "Taxonomy term: YOUR FIELD NAME FOR IMAGE"

So above steps should get your taxonomy term description and image in the view.

ahillio’s picture

Great D7 solution Mittal, thanks!

This worked in view displays, But how to get this into a views template file?

I have a working template file views-view-fields--event--panel-pane-1.tpl.php that's properly displaying the other fields, but not this one.

When I look at the theme info supplied in Views interface it says the id for this field is simply "description", but the following code is not printing the description
<?php print $fields["description"]->content; ?>

Is my code wrong? Or does the template file need something else to get the relation info? Something else?

haleagar’s picture

Thanks Mittal perfect.

And to get it into the view header as requested earlier in this thread.
Set field to Exclude from display.
Configure Header: Global: Text area
Check the box "Use replacement tokens from the first row"
in header use [description]

Hal Eagar
Software Architect
hal.eagar@door3.com

Stomper’s picture

Thanks for your tip.

I was able to expose the taxonomy but I want to specify specific fields from the taxonomy. My taxonomy is Locations and has Address Field fields associated with each terms, I'd like to expose only the "state" taxonomy field in my view.

My view is a EVA view involving Node References in an embedded table view.

How do I do that?