Find out if you're viewing a taxonomy page Clicking on a Taxonomy term generally takes you to a page showing several nodes which use that term. Is there a way to find out if you're viewing a specific vocabulary and save it to a variable? That way you can change the layout at will:

&lt;?php if( $is_vocabulary_fruits ) : ?&gt;
    Load this layout
&lt;?php if( $is_vocabulary_cars ) : ?&gt;
    Another layout different from the first
&lt;?php else : ?&gt;
    Nope, use this layout instead
&lt;?php endif; ?&gt;


I'm looking to place this in page.tpl.php. This means that the markup outside of the node.tpl.php is changed when viewing a taxonomy and not the node itself. How is this done in my template.php file?
When a taxonomy page is rendered, the template file used is taxonomy-term.tpl.php that receives, among other variables, the $term variable, which contains the term object for the taxonomy term associated to those nodes.
Basing on the vocabulary that owns that taxonomy term, you can change the layout of the page.

If you want to find out in page.tpl.php the taxonomy term associated with the nodes shown in the page (where the page's URL is example.com/taxonomy/term/[tid]), then you can use the following code:

$term = menu_get_object('taxonomy_term', 2);


If the page's URL is not example.com/taxonomy/term/[tid], then the function returns FALSE. The code can also be executed in a preprocess function, such as hook_preprocess_page().