By amnesia623 on
I need to theme Taxonomy pages on a client site and am finding out that D7 uses the node.tpl for its rendering of taxonomy pages.
How can I target either all and/or specific taxonomy pages for theming? There is a template in the core Taxonomy module, but that only controls the description of the term.
Is there a way to target Taxonomy pages via overriding tpl files?
Thanks!
Comments
I am having the same issue
Hi there, I shared the same issue. I just created a portfolio using Taxonomy and Content Types on Drupal 7. I noticed that there is a template file called "taxonomy-term.tpl.php" in the "modules/taxonomy" directory, copied it to my custom theme directory but I could not discover when it is used - you just said that it's used for describing a term, thanks.
Over that, I am afraid of having to use Views module (afraid to use such powerfull and complex module for a trivial task), if I need to change the ordering rule for Taxonomy items - rendering alphabetically instead od publish date.
Any help?
Same issue here, and so far,
Same issue here, and so far, Google didn't get me an answer... I will continue looking, though.
-=[o]=-
Views isn't that hard. It's probably way overkill for a simple theming problem but if you want to reorder you would either need to use Views or a template.php override which would be requiring sql queries. I fund Views quicker and easier personally :)
If you're bringing in new tpl.php don't forget to clear the cache or they won't pick up.
works at bekandloz | plays at technonaturalist
Simple solution
Drupal templating in general leaves a lot to be desired.
Here's one relatively clean way to do it. In my case, I thought it would be foolish to write template files that would be attached to a term's arbitrary numeric ID, because if you're actually planning to work in dev before making changes to a production site, your taxonomy terms may have different IDs in each place (since Drupal just hands them out at random.) For that reason, it makes no sense to name them things like: 'taxonomy-term--vocabulary--2345.tpl.php', and it makes more sense to be able to name them things like 'taxonomy-term--vocabulary--term-name.tpl.php'. To make that possible, since terms don't have machine names by default, I had to install this module: https://www.drupal.org/project/taxonomy_machine_name
Then you can do this:
If your vocabulary machine name is 'category' and your term machine name is 'cool_stuff', it'll now look for a template named:
taxonomy-term--category--cool-stuff.tpl.phpEmpty $term
I get a value on $vocabulary but nothing for $term (NULL). Any ideas why?
subscribe
subscribe
subscribing.
subscribing.
Views override
This seems to be related to http://drupal.org/node/948964. I posted a solution there.
subscribe
subscribe
Use template hook template_preprocess
There is a code snippet for Your template.php to do this :
I was inspired by this post for Drupal 6.
http://adaptivethemes.com/page-template-suggestions-for-taxonomy-vocabs
any one tried this code? did
any one tried this code?
did not worked for me !
Worked for me. You have to
Worked for me.
You have to create files like page--vocabulary--3.tpl.php
Thanks feo ;)
You need to replace the
You need to replace the function argument "&$vars" with "&$variables
I want to theme with
I want to theme with different vocabulary node not vocabulary page
nice one
nice one
I've spent the whole
I've spent the whole afternoon googling this topic and have gotten nowhere. I fancy myself pretty computer literate and nearly an expert in programming languages such as java, C++ etc but I must be a total moron with this topic.
All I see are thousands of replies showing two or three lines of snippets to a pre-process function.
I see no reference or linkage to any themes or css style comments. How does the code above end up changing anything in the theme?
Could someone help me find a tutorial for morons on this?
I have a custom theme based off the zen theme. I would like to customize the banner, logo and maybe some minor other styles based on where the viewer is in the taxonomy.
I found the zen css that sets these items but how do I switch based on taxonomy.
Another possiblity
Depending on what you want to achieve, you might just be able to alter the display of the teaser for a particular content type.
The taxonomy page displays the nodes in a teaser view. Go to the 'Manage display' settings for your content type, click on the Teaser tab, and you can select which fields you wish to display.
(Of course, if you're after changing the order of display, then you are going to need to delve into the template.php or views solutions described above).
Anyone has tried if it's
You may also try this module: http://drupal.org/project/tvi
Using views to override the default taxonomy page.
Thanks!
Drupaler China
Subscribe
Subscribing.
A block level override isn't too inelegant (for a hack)
It's certainly aggravating that there are no theme hooks for lists of things. There really ought to be a theme_preprocess_nodelist function hook and equivalent theme_nodelist[--source[--type]] template hooks. Just like there ought to be built in pages for listing contents of a given content-type (and I believe the two holes in extensibility are closely related). Views is powerful, but it's incredibly overpowered for so many simple things that should be achievable without any contrib modules at all. It would be nice to avoid that configuration-driven beast once in a while. Luckily, sometimes you can.
You can cheat your way around the lack of node listing (for taxonomy pages, at least) using HOOK_preprocess_block() like so:
Then create your block template like so:
Now you can do all the nice things you'd expect full theming control to enable like adding the pager to the top of the page, putting html between nodes, or creating special node views that output a table row or a list item, etc. (by altering the #view_mode property) and wrap that output in appropriate html.
I did it like this
taxonomy
Hello,
Please tell me how I can get this $build value in "page--taxonomy.tpl.php".
That code should go in a
That code should go in a module, not a template.
Are you sure ?
Are you sure ?
return Fatal error: Call to undefined function taxonomy_term_page()
for me.
taxonomy_term_page() its a
taxonomy_term_page() its a posible custom function that must return the contents that you wixh for your taxonomy page to have.
A useful module
You can do it with this module : Taxonomy display
David THOMAS
http://www.smol.org