Hello,
I am creating a theme that uses several css files. I want to load a different css file depending on the taxonomy term. If the term is "Animal" then load the animal.css file. If the term is "Human", then load then human.css file. This will result in the look and feel of the site being totally different, depending on which node is displayed and under which taxonomy term it categorizes.
When I put the <link rel...> statements in mytheme_page() function, I do not have the value of $node->nid yet, and therefore I can't switch to different css file. If I put the <link rel...> statements in the mytheme_node() function, it works fine, except that the theme logo doesn't change appropriately.
Any suggestions would be greatly appreciated.
Thanks in advance,
Kobus
Kobus,
i think you can use theme_add_style() for this inside your theme_node () function..
Stefan.
Op 9-mei-2005, om 9:15 heeft Kobus Myburgh het volgende geschreven:
Hello,
I am creating a theme that uses several css files. I want to load a different css file depending on the taxonomy term. If the term is "Animal" then load the animal.css file. If the term is "Human", then load then human.css file. This will result in the look and feel of the site being totally different, depending on which node is displayed and under which taxonomy term it categorizes.
When I put the <link rel...> statements in mytheme_page() function, I do not have the value of $node->nid yet, and therefore I can't switch to different css file. If I put the <link rel...> statements in the mytheme_node() function, it works fine, except that the theme logo doesn't change appropriately.
Any suggestions would be greatly appreciated.
Thanks in advance,
Kobus
-- [ Drupal support list | http://lists.drupal.org/ ]
Kobus,
The easiest way to accomplish this is to use either the pathauto module (http://drupal.org/node/17345), or my hierarchical aliasing patch (http://www.greenash.net.au/posts/thoughts/hierarchical_url_aliasing), to create hierarchical paths for your nodes (and terms) based on taxonomy. You can then use the sections module (http://drupal.org/project/sections) to apply a different theme to all parts of your site that start with a certain path.
I tried out using my patch, in conjunction with the sections module, on a development copy of my site (which is running 4.5). I created a new section, set its pages to be "services*", and then everything under the 'services' term on my site (i.e. nodes, child terms, and the root term itself - I would have done "services/*" if I wanted everything but the root term) suddenly had a different theme! I got this working within 5 minutes.
Jeremy.