0

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?

  • 3
    You are completely right about ThemeKey. While it does serve a specific purpose, it's usually best to keep everything in a single theme, if possible. – marcvangend Dec 1 '11 at 14:58
5

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.

0

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());
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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