Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By PapaGrande on
I have a D7 view page which is getting filtered by a Contextual Filter on a taxonomy term related to nodes. I simply wanted to display the relevant taxonomy term's description in the view header or a separate block, but I couldn't get it to work with a separate view using a contextual filter on the URL. The biggest hang up was getting it to work with URLs with dashes instead of spaces in the terms.
So I put the following code into a separate block:
<?php $current = taxonomy_get_term_by_name(str_replace('-', ' ', arg(1))); ?>
<?php $key = current(reset($current)) ; ?>
<?php if ($current): ?>
<div class="taxonomy-description">
<?php print( $current[$key]->description) ; ?>
</div>
<?php endif; ?>
This seems very kludgy. What's a better way to do this in D7?
Comments
Did you get a solution for
Did you get a solution for that?
Found a solution
- add a relationship to the taxonomy term: "terms on node"
- create an attachment display
- make the attachment field the term description