I have a taxonomy vocabulary (Authors) which is used only for the Books content type. What I would like to achieve is to create a file (taxonomy-term--authors.tpl.php) in which I can customize the HTML markup.

  1. Currently when I create the file I can only more static markup instead of modifying the output of the books which contain the specified term.

  2. I also tried to use the mytheme_preprocess_page() and give a template suggestion but when I add content to the file it's not rendering how I would expect. It does not include header/footer styles and other stuff.

I also tried using Views module but the behavior is similar to first point 1.

  • 1
    you should use views, and then use views configuration to control the output of each book. you can pick a view mode in which the books should be displayed. and then you can use field ui, display suite, and/or node templates to control the book output for the view mode. – donquixote Aug 30 '15 at 4:00

You can have full control over the taxonomy/term/ID page by intercepting the menu call with hook_menu_alter() and let the content be generated by a custom function.

This allows you to completely customize the taxonomy term page. You can check for a certain vocabulary ("Authors") and have a custom generated page for that vocab and leave the others untouched.

You can have fine grained control over how results are displayed using view modes and templates.

No contributed modules are needed.

Here is an example to be used in a custom module. The custom content is generated using Drupals EntityFieldQuery because it is a lazy and robust way of generating a list of content, but anything goes here. .

 * * Implements hook_menu_alter(). 
function YOURMODULE_menu_alter(&$menu) {
  if (isset($menu['taxonomy/term/%taxonomy_term'])) {
    $menu['taxonomy/term/%taxonomy_term']['page callback'] = 'YOURMODULE_taxonomy_term_page';
    $menu['taxonomy/term/%taxonomy_term']['access arguments'] = array(2);

 * Callback function for taxonomy/term/%taxonomy_term. 
 * @param $taxonomy_term object
 * @return * Themed page for a taxonomy term, specific to the term's vocabulary. 
function YOURMODULE_taxonomy_term_page($term) {
  $voc = taxonomy_vocabulary_load($term->vid);
  switch ($voc->machine_name) {


      // here you generate the actual content of the page
      // could be done e.g. with an entityfieldquery as follows

      $query = new EntityFieldQuery();
      $query->entityCondition('entity_type', 'node')
              ->fieldCondition('field_gallery', 'tid', $term->tid)
              ->propertyOrderBy('sticky', 'DESC')
              ->propertyCondition('status', 1);
      $result = $query->execute();
      if (!empty($result['node'])) {
        $build['content']['nodes'] = node_view_multiple(node_load_multiple(array_keys($result['node'])), 'teaser'); // output the node teasers. you can control the markup of the 'teaser' view mode with a template in the theme folder
      } else {
        $build['content']['status']['#markup'] = t('No results found for term ID !tid.', array('!tid' => $term->tid));
      return $build;

    // If the term page is for an other vocabulary then use Drupal's default taxonomy page 
      module_load_include('inc', 'taxonomy', 'taxonomy.pages');
      return taxonomy_term_page($term);
  • take care with the access arguments entry, if you dont need it, skip it, otherwise you get permissions issues, and also an error like Illegal offset type in isset or empty in … – rémy Jul 21 '15 at 11:41

Try this code:

 * Implements hook_preprocess_taxonomy_term().
function YOURTHEME_preprocess_taxonomy_term(&$variables) {
  if ($variables->vid == YOUR_VOCABULARY_ID) {
    $variables['theme_hook_suggestions'][] = 'taxonomy_term__authors';

You can use the Taxonomy Views Integrator, or its working patched version.

Navigate to yoursite.com/admin/structure/taxonomy/yourtaxonomyvocabulary/edit and choose your view and view display for every vocabulary you have.


Each term has link taxonomy/term/TERM_ID and if you want vocabulary based theme(customize HTML markup) on terms pages then you can use "Taxonomy Views Integrator" module.

On particular vocabulary edit page you can select views template. And in that views template you can write customize html so, that pages with taxonomy/term/TERM_ID get themed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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