By Z2222 on
I'm overriding my default taxonomy display with a file called page-taxonomy.tpl.php. It overrides all taxonomy pages but I only want to override vocabulary #3.
I tried things like page-taxonomy-3.tpl.php but that didn't work
I also tried to print variables with this, but I couldn't find any variables that conain the vocabulary used:
<?php
print '<pre>';
print_r(get_defined_vars());
print '</pre>';
?>
Any ideas on how to override the taxonomy page for just one vocabulary? Or to put a conditional statement in page-taxonomy.tpl.php that will only print a sentence if the page is displaying teasers from vocabulary #3?
Comments
subscribing
subscribing
you can use arg(0) .. to
you can use arg(0) .. to access taxonomy tid then you can write a code like this:
The solution is to create a
The solution is to create a template file only if the term parent is x.
Example:
page-taxonomy-term-#.tpl.php
The easiest way is to name the file as such...
page-taxonomy-term-#.tpl.php
# of course being the taxonomy term # you want to display
But the question is how to
But the question is how to get a special tpl for a VOCABULARY, not a term
EDIT: The answer was already there... kinda.
For drupal 6 this one works fine for me:
In template.php:
Now you can override the page.tpl for each vocabulary by it's id:
page-taxonomy-vocabulary-1.tpl.php
page-taxonomy-vocabulary-2.tpl.php
...
EDIT 2: didn't see this was for D5... sorry
I attempted this solution but
I attempted this solution but the changes don't seem to have taken effect.
Is there anything site-specific I have to add to the template.php file in order for this to work? I am using D6.
Not that i know of. You did
Not that i know of. You did clear the cache after applying?
Thanks for your response
Thanks for your response l0calh0rst. I did clear the cache, yes.
When I entered the update on the template.php file, I suddenly couldn't access Views, Blocks and several other admin areas. Just white screens...
On the code which you have shown to enter in template.php, does the vocab number have to be inserted?
As in:
Thanks, in advance.
The vocab id is stored in the
The vocab id is stored in the $term object ($term->vid).
The example is missing a "}"
The example is missing a "}" at the end.
Thanks
Thanks for that austinh7! I have got it working now. It's amazing how something so simple can be the culprit.
Slight change for Drupal 7
taxonomy_get_term has become taxonomy_term_load & $vars['template_files'][] has become $variables['theme_hook_suggestions'][]
Ian Norton
As already mentioned, there
As already mentioned, there is a missing } . I just wanted to add that it is not good practice to add a hashtag into filenames.
Here is the code for all y'all who want to copy/paste it. Just remember that you use the Vocabulary ID not the name.
Example template file name: page-taxonomy-vocabulary-1.tpl.php
cheers to this!
cheers to this!