[drupal-support] Change theme by taxonomy

Kobus Myburgh ITBJDM at puknet.puk.ac.za
Mon May 9 15:50:25 UTC 2005


Hello!

I just want to thank everyone for their assistance with this problem. It is in the end Stefan's help that pulled me through, and everything works now. The reason why it didn't work initially is that I failed to register that the theme_node() function gets called more than once per page. Stupid me. I can now include different style sheets when the taxonomy terms differ per node.

Thanks again!

Kobus


>>> ITBJDM at puknet.puk.ac.za 5/9/2005 4:18:16 PM >>>
Stefan,

Thanks for the info. This is how I initially had it, but somehow that didn't change the theme appropriately. I will look at it again though...

Regards,

Kobus


>>> Drupal-Support at iStyledThis.nl 5/9/2005 4:07:38 PM >>>
Well, inside theme_node() you can use $node, using $node->nid returns  
the node->id..
By using taxonomy_node_get_terms() or  
taxonomy_node_get_terms_by_vocabulary() you can get the term(s),  
which are related to your node..

See these urls:
- http://drupaldocs.org/api/4.6/function/taxonomy_node_get_terms 
- http://drupaldocs.org/api/4.6/function/ 
taxonomy_node_get_terms_by_vocabulary

The putting this inside a select ase, ouldn't make it very hard to  
add the stylesheets imo..


Stefan

Op 9-mei-2005, om 15:53 heeft Kobus Myburgh het volgende geschreven:

> Being hardcoded into the theme is not a big problem, because for  
> the site I intend to use it, I will have only about 5 or 6  
> categories, so that's fine. It's for a media company, and they have  
> a fixed set of magazines that they publish. I suggest the movement  
> per year will be maximum one or two categories per year.
>
> Maybe I should just ask someone who knows the intricacies of Drupal  
> very well to tell me:
>
> How do I get the value of $node->nid so that I can <link rel...>  
> the correct stylesheet depending on the taxonomy term? If I have  
> $node->nid, then I can get the taxonomy term name for that nid, and  
> then link the correct stylesheet.
>
> Regards,
>
> Kobus
>
>
>
>>>> Drupal-Support at iStyledThis.nl 5/9/2005 3:26:56 PM >>>
>>>>
> Kobus, it will work, but the problem/disadvatage is that it will be
> hardcoded in your theme..
>
>
> Op 9-mei-2005, om 15:19 heeft Kobus Myburgh het volgende geschreven:
>
>
>> Stefan,
>>
>> I will check this out as well, as see if this works for me. As I
>> said previously, I will provide feedback.
>>
>> Thanks!
>>
>> Kobus
>>
>>
>>
>>
>>>>> Drupal-Support at iStyledThis.nl 5/9/2005 10:13 AM >>>
>>>>>
>>>>>
>> 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/ ]
>>>
>>>
>>
>> -- 
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>> -- 
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
>
> ---
> Stefan Nagtegaal
> http://www.istyledthis.nl/ 
>
>
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]
>
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]

-- 
[ Drupal support list | http://lists.drupal.org/ ]

-- 
[ Drupal support list | http://lists.drupal.org/ ]



More information about the drupal-support mailing list