Drupal - Taxonomy Description in View

Kevin's picture

[b]Q:[/b] How do I arrange for the taxonomy term description text to be displayed when I use the built in 'taxonomy_term' view to handle the display of my taxonomy lists?

[b]A:[/b] You can get the text to display by enabling the view's header and adding in some PHP code which queries and displays the text...

The 'taxonomy_term' view is a fantastic alternative to drupal's built in taxonomy display mechanism. You can use it to customise the living daylights out of your taxonomy display, especially if you use it in conjunction with modules like [url=http://drupal.org/project/taxonomy_image]Taxonomy Image[/url]. We have used it a lot recently on our web sites when the web design calls for displaying grids of products with product pictures and the like.

Anyway, the view has one small problem in that it doesn't display the taxonomy term's description text at the top of the page in the way that the default taxonomy display method does.

After some searching we found a way to easily get the view to display the description text here (see the comment on Nov. 2008 by Guix):

http://www.norio.be/blog/2008/10/displaying-taxonomy-term-description-to...

Here are the steps we used:

[img]/sites/default/files/images/tax-description.png[/img]

(1) Enable the view's Header

(2) Set the header's input format to PHP

(3) Paste in Guix's PHP code:


if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
$tid = (int)arg(2);
$term = taxonomy_get_term($tid);
print (filter_xss_admin($term->description));
}
?>

This code gets the taxonomy term id from the url, uses it to load the corresponding taxonomy term and then pulls out and prints the term description text.

(4) Press Update & Save View

Now when the view is displayed it should insert the taxonomy description txt at the top.

It worked really well for us and we're very grateful to Guix for the tip - cheers, it really helped us out!

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c