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
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.