Add site name and/or site domain as CSS class to body tag.
Would assist when using same theme for two similar sites. Currently I am using both CSS Injector and Skinr to avoid issues where block numbers and node IDs clash.
Contextually declaring these classes would solve the issues.

EG: body.sitename-a #block-7 V body.sitename-b #block-7

Comments

Jeff Burnz’s picture

Right, do you mean for a multi-site? Sounds like smart idea to me.

Jeff Burnz’s picture

OK, this can be done quite easily in preprocess, pretty sure this variable never changes...

    // Site name class
    if (!empty($vars['head_title_array']['name'])) {
      $vars['classes_array'][] = 'site-name-' . drupal_html_class($vars['head_title_array']['name']);
    }

So this will make a body class as: .site-name-foobarsite

Thoughts?

BarwonHack’s picture

Hi Jeff - Yes for multisite.

I'm building two sites (one a public site, the other an extranet) that share the same theme. Decided not to use domain module as it tends to un-necessarily complicate life (IMHO unless the actual content is shared).

Your solution sounds great.

The one issue I was concerned with was the class changing between environments (EG: dev.sitename V www.sitename). But then this could actually be quite useful. So perhaps declaring the sitename and the url would be best. then you could effectively style using just the siteName, just the siteURL or with multiselectors (EG: body.sitename.siteurl) if required.

Cheers Jeff ++

Jeff Burnz’s picture

I don't want to add the domain class due to performance reasons - the site name is available for free in the $vars array, however the domain name I have to "GET" and will incur the a cost, albeit very small cost its not a commonly used feature, so I am not sure it passes the cost/benefit ratio. I am very weary of performance overhead in this theme because its a large and complex theme, it's easy to get carried away with features. Right now the performance is good, very good actually, so even very small features such as the domain class are coming under scrutiny.

BarwonHack’s picture

Totally agree Jeff. Thanks again for all your great - and hard - work.

(Is this in now dev?)

Jeff Burnz’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

yes this is now in dev, 7.x-3.x, but it just go committed a short while ago, it can take 24hr for the downloadable archive to update.

Jeff Burnz’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev

Ok, so now I think we backport this to 7.x-2.x.

Jeff Burnz’s picture

Status: Active » Closed (fixed)

Fixed in 2x.

Jeff Burnz’s picture

Issue summary: View changes

Add ID to block CSS example