I am using drupal 7. I wanted to change the colors of the block and everything for certain pages. The ThemeKey module works fine but i have to do all the block configurations again in this. This is tedious. Since i want to change only the css any other module will solve ma problem?
2 Answers
The body
element will have a boatload of classes on it. This does vary by theme, but typically there will be a class like
body.page-the-url-for-this-page
that you can use in your CSS.
Do a view source on various pages and take a look. Or, use the Inspect Element feature of Firefox's Firebug or Google Chrome, or the Firefox Web Developer extension.
If the class isn't there, you can do something like
function thetheme_preprocess_html (&$variables)
{
$variables['classes_array'][] = "page-" . str_replace("/", "-", request_uri());
}
You may also want to investigate the Context module, which can aid in section-specific features for a site.
This is a good approach, and very succinct. I think the following code works better, since 'replace' throws an error:
function thetheme_preprocess_html (&$variables)
{
$variables['classes_array'][] = "page-" . str_replace("/", "-", request_uri());
}