I need to have a special class for example for body element which will be showing me on which site from multisite installation I am in. Here is a solution loading different css files but is there a way to have a simple class?

2 Answers 2


Well i decided to use different .css files with this code:

// Allow a site-specific user defined CSS file (useful for multisite installations):
// If a CSS file "local-[SITE].css" is residing in the "css" directory (beside "local.css"),
// it will be loaded after "local.css". SITE is the site's host name, without leading "www".
// For example, for the site http://www.mydomain.tld/ the file must be called called "local-[mydomain.tld].css"
global $base_url;
$site = preg_replace("/^[^\/]+[\/]+/", '', $base_url);
$site = preg_replace("/[\/].+/", '', $site);
$site = preg_replace("/^www[^.]*[.]/", '', $site);
drupal_add_css(path_to_theme() . '/css/local-[' . $site . '].css', 'theme', 'all');

I would recommend you to create a custom module where you can store individual settings for each domain. Create for example a simple textfield where you can enter the class you would like to have in your body tag from this site. Use these settings then in your template preprocessor to add for example a class to the body.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.