taxonomy_term_page.tpl.php

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
monti's picture

have tried to implement a taxonomy page similar to what's done in this podcast - http://mustardseedmedia.com/podcast/episode31

unfortunately, my taxonomy_term_page.tpl.php file is not being processed.
did i miss anything? is there any hidden undocumented magic that makes it work?

Cheers !

Comments

Different name

kerberos's picture

I don't remember off the top of my head, but I think it may be something like this instead:

page-taxonomy-term.tpl.php

Take a look at the comments to the podcast, someone mentions it there.

-Daniel
Urbopedia.ro

you've got it right

monti's picture

It works now.
Thanks man !

Found another cause and solution to this

Andyscc's picture

page-taxonomy-term.tpl.php is a solution, but it doesn't allow you to pass an argument into the page from the view.

We eventually found that having the "taxonomy_term (default)" view enabled was preventing the taxonomy_term_page.tpl.php from being processed. Once we disabled the taxonomy_term view the override page used in the Mustardseed demo began working and all was well.

Hope that helps, it took us about 8 hours to figure this out.

thanks

divbox's picture

disabling this helped me too. was going nuts :)

per one of the comments in the mustardseedmedia article, i think it is best from a performance perspective to use template.php instead of the .tpl.php file

add this to template.php -- replace YOURTHEME w/ your theme name and YOURVIEW w/ your view name.

function YOURTHEME_taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
  $output = '';
  $viewName = 'YOURVIEW';
  $display_id = 'block_1';
  $output = views_embed_view($viewName, $display_id, $str_tids['0']);
  return $output;
}

Thank you

James-TRMS's picture

This is very helpful but being a newbie to php I can't make it work for multiple blocks so have had to revert to the solution in the video. I would prefer to follow this route if possible. Is what I am missing something simple?

Thanks!!

tahiche's picture

I´ve been stuck on this for 4 hours!!.
How the hell did you figure it out?. I would have never thought of this!!. Whats the relationship between the two?.
My function stopped working all of a sudden and I wouldn´t have figured it out in 80 hours without your post.
I was pulling my hair because not only I couldn´t override the function in my template.php but changing the function in the .module had no effect either...
This should be commented somewhere!!

Thanks!!

I know this post is a few

wxman's picture

I know this post is a few months old now, but I'm going nuts trying to do this. I too followed the video, and the advice about the default view, and got it to work just fine. My problem is, I need it to display whole pages, not just blocks. I figured out to use:
$display = $view->execute_display('page_1',$tids)
instead of
$display = $view->execute_display('block_1',$tids)
but that's still not the answer to my problem.
Somehow, I need to come up with a way to display different content types, using different taxonomy's, all in different formats.
We have a book based site, and we use many different taxonomy terms to categorize them all. On the pages displaying just books, I want it to be two a two column grid, showing just a thumbnail cover, and a bit of the book info. I did that easily using the above techniques. What messes things up is that on the other taxonomy listed pages, we'll have articles, or news items, with just a title, and a teaser. They use a completely different taxonomy from the books, and I can't figure out how to display them like a normal taxonomy page. To make the new book list look the way I want, I have to remove the default view, then only the books pages work. None of the other taxonomy's display anything.

Hopefully this is 'better late than never...'

arpieb's picture

You could probably still use the Views-based approach, but set your row style to "Node" instead of "Fields" and pick the "Teaser" build mode (this way you get an abbreviated rendering of each node returned by Views). This will force your content to return to the Views display processor as full nodes vs. individual fields, which will in turn run them through the normal node theming process, creating the themed "teaser" version of the node. No more worrying about cherry-picking specific fields.

Then, make sure your Filters are only filtering based on something common to all content types (or filter to only the specific content types you want to show in your listing). Usually "Published" and maybe a range of valid "Node Types" will do the trick here.

Finally, you can create node-XXX.tpl.php templates as needed for each content type (if the base node.tpl.php doesn't work for that specific type) and make sure that you maintain the teaser vs. full-node rendering logic found in the base node.tpl.php file that you derive your content-type-specific TPL file from.

Refresh your theme registry and away you go! What you should get is a listing of node teasers that have each been formatted based on their respective node-XXX.tpl.php templates, and where you don't have a specific content-type template, the generic node.tpl.php template will have been applied.

NOTE: an alternative is to use the Contemplate module if you're not comfortable with TPL files, as well as tweaking the "Display Fields" in the content type definition to limit what is shown in the Teaser vs Full rendering of the node.

Doh!

arpieb's picture

I just realized I was answering another post on a similar topic in the wrong window... The good news is, the above solution will work for mixed content types on a single custom taxonomy page... ;)

You might look into the Context module as it has a very powerful conditional filter for rendering different page layouts based on various content and path criteria. It might do what you are looking for...

Otherwise you're going to probably have to look into using strictly Views-driven Taxonomy listings or coding conditional logic into the template.php file and/or the taxonomy TPL file...

I have found that

adpo's picture

I have found that Internalisation module was preventing taxonomy_term_page.tpl.php to work.

same here

castawaybcn's picture

@adpo, I know this is really old, but I think I am running into the same problem. Did you find a way to do work this out with internationalisation? Thanks!

Urgent Help

joshiparthin's picture

Im in drupal7, i need to change the dispaly format of contents matching terms from page wise teasers to table. I could have worked on Views API, but I am using taxonomy subterms module which does not work on Taxonomy overriden view.

So i am try to change the code of taxonomy_term_page(). I know its a bad idea, but need to fix this ASAP.

I want to change something over here :

if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
$nodes = node_load_multiple($nids);
// $my_view = views_get_view('product_listings');
// $build += views_build_view('embed', $my_view);
$build += node_view_multiple($nodes);
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
);
}

Instead of node_view_multiple, i need to a view to be inserted over here. I tried views_get_view() but no use.

Please assist.

Thanks,

Parth J Joshi

When I enabled that view all

afaaro's picture

When I enabled that view all other taxanomy pages are blank page. anyhelp

I realised this workaround isn't needed in drupal 7.

tgldesign's picture

I came across this problem after upgrading from drupal 6 to drupal 7.

I used to use the mustardseed media thing for drupal 6 by rendering a view through taxonomy_term_page.tpl.php but now you can do way more with the standard "Taxonomy term" view. I just disabled my old custom taxonomy page view, then enabled and started editing the standard Taxonomy term view how I wanted it to look, with just titles and images linking to their nodes.