How to add site name in body classes in Drupal 7
Blog

How to add site name in body classes in Drupal 7

Recently, we worked on a multi-site Drupal 7 project where we required a certain site specific CSS. In our project, all sites were using one common theme, though each of them had unique configuration and content.

Googling for a solution showed up a few methods, but none of them worked exactly as we needed. For instance, the Adaptive theme module has settings to add site-name-hidden class if Site Name display is not selected on theme settings page. However, we did not want the site name hidden; we wanted it to be shown.

Finally we were able to by using context module. And these are the screenshots showing how you, too, can do it:

Step 1: Add new context

Step 2: Add new condition
Select Context Condition - Sitewide context

Step 3: Add Reaction
Select Context Reaction - Theme HTML

You are done. After saving you should be able to see your sitename in bodyclass.
Sitename in Body Class
 

Valuebound is a leading Drupal development company providing enterprise Drupal web solutions. For more information on Drupal development, contact us

Download the Drupal Guide
Enter your email address to receive the guide.
get in touch