Within my view, I'm using a contextual filter—with a default "summary output"—to filter my results by taxonomy term.

The problem is that the summary-result is grouped by a listing of taxonomy term-id's (including a node count) and not human readable term-id names.

  • 1 (21)
  • 2 (16)
  • etc.

Is it possible to change (or hook) the view output of the summary, by not listing its term-id's, but the term-id-name?

  • Term name A (21)
  • Term name B (16)

(It doesn't bother for me if the actual request URL stays the same.)

My goal is to create a more readable output-format of my taxonomy-term summary, which an end user can understand.


3 Answers 3

  1. Set your view to fields and expose the field that contains the associated taxonomy term.

  2. Set your contextual filter to filter for a taxonomy term and select to include a validator.

  3. Set the validator to taxonomy term and check the box for your vocabulary.

  4. Select the option for filter value type as ' Term name converted to Term ID.

  5. Save the filter and go to the preview box. If you enter the text name of your term, you should see the desired content.

If you are passing the information from the URl you may have to select the 'Transform dashes in URL to spaces in term name filter values' checkbox as well since the machine name uses dashes

  • Something I had forgotten was that when selecting a contextual filter, it has to be for Taxonomy Term (name) and use a relationship with the field on the nodes you are displaying to the term itself, rather than Content: my_term_field_name
    – CR47
    Mar 10, 2015 at 18:50
  • This answer tells you how to make the contextual filter work with the human readable name of the taxonomy term, but it does not answer the question. The question is how to display the human readable name of the taxonomy term in the filtered results. Jun 18, 2019 at 23:43

Copy the "views_view-summary.tpl.php" file your "modules/contrib/views/theme" folder. (You can make it view or block specific by adding a filename-suffix.)

Note: If you use this as a admin view-display, make sure you copy this file within the admin theme folder, not your default theme folder!

You don't need any changes in your display-settings. Just adjust your tpl-override to the following lines, and your Term-ID's are converted to readable Term-names:

<div class="item-list">
  <ul class="views-summary">
    <?php foreach ($rows as $id => $row): ?>
      <a href="<?php print $row->url; ?>"<?php print !empty($row_classes[$id]) ? ' class="'. $row_classes[$id] .'"' : ''; ?>>
        /* begin replacement */
        $term_object = taxonomy_term_load($row->link);
        print  $term_object->name; 
        /* end replacement*/
      <?php if (!empty($options['count'])): ?>
      &nbsp;(<?php print $row->count?>)
      <?php endif; ?>
    <?php endforeach; ?>

There is an article on Drupal easy: Using display attachments to provide a consistent summary in Views 2.

  • With your example or for example based on a node-title as a contextual filter, it is working properly. But in my question the contextual filter is based on it's Taxonomy term. In this case the summary will display only the Term ID's and you are unable to show the more - readable - Term names. Oct 4, 2011 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.