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.
By jorisx on
For some tiny thema tweaks in a multisite project I needed to add the domain as class to the body..
I'm not that good in php but i fiddled around and came with this solution for in the template.php:
// add domain as class to body
function THEMENAME_preprocess_html(&$vars) {
$site = preg_replace('!^[^.]*\\.!','', $_SERVER['HTTP_HOST']);
$site = str_replace ( '.', '-', $site );
$vars['classes_array'][] = 'domain-' . $site;
}
It works for me now :) but maybe it is in desperate need of some modification so I put it here :)
And for future reference...