I want to render a Taxonomy term in a Header for a Page view which uses the Taxonomy term as a Contextual filter. I found that I can add an Entity: Rendered entity to the Header of a View, which I can set to display a Taxonomy term, but it needs an Entity ID, and I don't know how to reference the Contextual filter value.

I suppose I can use a Global: PHP or Global: View in the header to achieve this otherwise, but I wanted to know whether I can use the Rendered entity to do this.

1 Answer 1


It looks like this isn't currently possible. There's a feature request on d.o to make this work. You can achieve it with Views PHP as you mentioned by using the following code:

$entity_type = 'taxonomy_term';
$id_arg = 1;
$view_mode = 'full';

if ($entity_id = $view->args[$id_arg - 1]) {
  $entity = entity_metadata_wrapper($entity_type, $entity_id);

  // Rendering without title ($page = TRUE).
  $render = $entity->view($view_mode, NULL, TRUE);

  // You may need to unset the title, even when rendering without it.
  $render[$entity_type][$entity_id]['#term']->name = NULL;
  print drupal_render($render);

Note: this code requires the entity module. Shouldn't be hard to port it to native Drupal code, but entity is rather widespread.

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.