Hi there.

I have a view page that displays only nodes which use a specific taxonomy term (filter). Now I want to display the description of this term as the title of the view page.

I searched the forums and tried out a couple fo things but to no avail. Any help appreciated!

Comments

tekken’s picture

1) Create a different template for the taxonomy page: http://drupal.org/node/104316

2) In the title of page-taxonomy.tpl.php

<h1 class="title">
<?php
$current = taxonomy_get_term(arg(2));
echo $current->description;
?>
</h1>
summit’s picture

Subscribing, also solution available for panels page title with node-overrule please?
Greetings, Martijn

tekken’s picture

visualnotion’s picture

Thank you, tekken, for posting this solution.

I was able to just add this to my page.tpl.php file and it works great without having to create a new template file (in the original poster's post, they needed it as the page title.):

<?php $current = taxonomy_get_term(arg(2)); ?>
<?php if ($current): ?>
    <div class="taxonomy-description">
        <?php echo $current->description; ?>
    </div>
<?php endif; ?>

--
VN

giggler’s picture

I placed this in page.tpl.php and it worked for all taxonomies under a vocabulary, but it did not work if I placed it in page-vocabulary.tpl.php. Any ideas why?

Also how do you do this for top level vocabularies because it didn't show up for the vocabulary when I did put it in page.tpl.php and only showed up for all the terms under the vocab...Thanks!!!

summit’s picture

Hi, Maybe stupid. But shouldn;t it be page-taxonomy.tpl.php ?
greetings, Martijn

giggler’s picture

Yeah, I have a page-taxonomy.tpl.php but I think the php code needs to be something with taxonomy_get_vocabulary, but I don't know what it should be since trying different taxonomy_get_* didn't work....

jasom’s picture

Yu must put this code to title and select php filltering :)

pixelite’s picture

You can also add this snippet right into the view's header by turning on PHP filter module and choosing PHP as the input format.

giggler’s picture

thanks - that worked... =)

rafaeldwan’s picture

Found this in another thread, here's how to make it work in D7. First make sure PHP Filter is enabled in Core Modules, as Pixelite says above, then add this to your view's header :

<?php $current = taxonomy_term_load(arg(2)); ?>
<?php if ($current): ?>
    <div class="taxonomy-description">
        <?php echo $current->description; ?>
    </div>
<?php endif; ?>

(taxonomy_get_term replaced with taxonomy_term_load to make this work in D7, originally posted by traceelements here: http://drupal.org/node/1046588)

wwwoliondorcom’s picture

How to fill term description automatically

Hello,

Do you know how to complete terms pages automatically ?

I mean at least copy the same term word to the description and keywords fields.

Thanks a lot.

ressa’s picture

I am also trying to give taxonomy views a meta description, does anyone know how to do that?