View page title from term description

tekken - June 29, 2008 - 13:54

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!

Solution

tekken - July 6, 2008 - 10:03

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>

Subscribing, also solution

Summit - July 6, 2008 - 10:08

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

Do you mean...

tekken - July 6, 2008 - 10:19

Thank you, tekken, for

visualnotion - April 7, 2009 - 03:20

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; ?>

I placed this in page.tpl.php

giggler - April 14, 2009 - 05:24

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!!!

Hi, Maybe stupid. But

Summit - April 14, 2009 - 07:41

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

Yeah, I have a

giggler - April 16, 2009 - 19:18

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....

just for people like me

jasom - May 21, 2009 - 08:41

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

You can also add this snippet

pixelite - April 20, 2009 - 22:16

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.

thanks!

giggler - April 21, 2009 - 02:14

thanks - that worked... =)

 
 

Drupal is a registered trademark of Dries Buytaert.