AnswerBun.com

hiding taxonomy terms on term page

Drupal Answers Asked by user3027413 on December 21, 2021

I’m struggling theming the taxonomy-term page and since i’m not really getting anywhere, i now embedded two blocks (created with views) in my taxonomy-term.tpl.php. Now, that views is showing everything the way I want it, I don’t want the term page itself output its data.
That’s why I’m trying codes like

<?php hide($content); ?>

But that won’t do the trick. How can I just show the Blocks from Views instead of the content taxonomy provides itself?

Thanks!

One Answer

Use Display Suite to manage your display and show/hide fields for Taxonomy terms. You can actually display nothing. Then add the blocks in there.

Second option is alter taxonomy term page.tpl.php - a function that you need to add in template.php within your theme directory.

This is a function for templating pages for content types or terms. Second part defines page--taxonomy--term.tpl.php suggestion. It worked for me.

<?php
/**
* Add / modify variables before the page renders.
*/
function YOURTHEMENAME_preprocess_page(&$vars) {
// custom content type page template
  // Renders a new page template to the list of templates used if it exists
  if (isset($vars['node']->type)) {
// This code looks for any page--custom_content_type.tpl.php page
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
    if(arg(0) == 'taxonomy' && arg(1) == 'term') {
        $tid = (int)arg(2);
        $term = taxonomy_term_load($tid);
        if(is_object($term)) {
           $vars['theme_hook_suggestions'][] = 'page__taxonomy__'.$term->vocabulary_machine_name;
        }
  }
}
?>

I hope it helps. A while ago, I've been looking for this solution for days!

Answered by designarti on December 21, 2021

Add your own answers!

Related Questions

Make node only accesible by path alias

3  Asked on November 19, 2021 by kevin-ramirez-zavalza

     

Form and gated content

1  Asked on November 17, 2021 by dataguy

 

Calculate Star rating based on webform submissions

1  Asked on November 17, 2021 by brainhax

 

Pager not working when $form[‘table’] is called with AJAX

1  Asked on November 17, 2021 by user3428971

     

Send message notification when license expired

1  Asked on November 15, 2021 by learner123

 

View filtering, Relationship Vs Contextual filter

1  Asked on November 15, 2021 by bassem-mohamed

   

Missing some block fields

1  Asked on November 15, 2021 by metalbearsolid

   

Custom template for each profile2 profile type edit form

1  Asked on November 13, 2021 by stavovei-ciprian

       

How to save an image resource

1  Asked on November 13, 2021 by kosher

 

How to alter node body content through Views pre render hook?

1  Asked on November 11, 2021 by pramodg

 

Set Default Value for Image Field contain Multiple Images

1  Asked on November 11, 2021 by pglatz

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP