Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My first Drupal site used a subtheme of Zen, which included content-type body classes, so I could, for example, have different CSS styles for Blog entries than for Stories.
I'd like to do the same in a new site I'm working on, using my own custom subtheme of Danland.
I found this: http://drupal.org/node/162485
But I'm not a programmer, so I don't know how to incorporate that code in a way that also maintains the "sidebars-1" and "sidebars-2" body styles that already exist in Danland.
Any help would be greatly appreciated.
Comments
Comment #1
danpros CreditAttribution: danpros commentedHi,
To add that classes without disturbing existing ids and body classes you can try the following steps:
with this:
To this:
Let me know if not working. Do not forget to clear the cache. I will updating the handbook for other users.
Dan
Comment #2
danpros CreditAttribution: danpros commentedScroll to the bottom for more advanced body classes.
Comment #3
Katrina B CreditAttribution: Katrina B commentedThanks. It's a good start. I recently located a more extensive set of code that covers pretty much everything I'd like to do with body classes:
I'd appreciate some help with how to incorporate it into the Danland theme. Thanks.
Comment #4
danpros CreditAttribution: danpros commentedHi,
Follow the first step of my comment above then replace the whole template.php with this:
Dan
Comment #5
Katrina B CreditAttribution: Katrina B commentedGreat. Thanks! My only worry is that my taxonomy terms are showing up in the body classes with the capital letters still in place. I should be seeing "tax-audition" as a class, but I'm seeing "tax-Audition" instead. Any suggestions?
Comment #6
ishmael-sanchez CreditAttribution: ishmael-sanchez commentedwrap the term name in the PHP function string to lower function ex.
$body_classes[] = 'tax-' . strtolower(eregi_replace('[^a-z0-9]', '-', $term->name));
Comment #7
danpros CreditAttribution: danpros commentedThanks ishmael-sanchez,
Yes but since we already creating the function for that so just call it:
Comment #8
Caesar CreditAttribution: Caesar commentedhi, i want to give a different colour to danland sheet so that the background colour is not the same as the sheet colour
Comment #9
grkm2002 CreditAttribution: grkm2002 commentedHow do you achieve the results on this page for drupal 7 or is it already incorporated into the page-tpl.php file.