0

I would like to add some custom stylesheets for specific theme.

for example: Bartik is default and Seven is the Administration theme.

In this case, I want to add some custom styles for only Bartik front-end theme.

How can I customize the following code for the Bartik theme?

<?php
/**
 * Implements hook_init().
 */
function mymodule_init() {
    $path = drupal_get_path('module', 'mymodule');
    drupal_add_css(
        $path . '/custom.css',
        array(
            'group' => CSS_THEME,
            'every_page' => TRUE,
        )
    );
}
?>
1

Actually, what I would do is I would make my own sub-theme that uses Bartik as a base theme and add the additional css stylesheets to my sub-theme's .info file like this:

stylesheets[all][] = css/MY-CUSTOM-CSS-STYLESHEET.css

Just look at Bartik's own .info file to see how it adds stylesheets and javascript files as an example!

Here is some info on how to create a sub theme: http://drupal.org/node/225125.

The best thing about creating a sub-theme rather than adding these stylesheets using a custom module is that you'll be all set to do things like adding or overriding theme images, modifying template files and tackling a big array of potential customizations you may want to do in the future that you may not even be for-seeing now! It'll just end up being more flexible in the long run.

  • My goal is to distinguish between frontend and backend development phases. and also there are still some bugs on hook_form_system_theme_settings_alter ajax callback. drupal.org/node/1296362 I think it would be good to move advanced theme settings into a custom module that is associated with a specific theme. – kLezer Feb 27 '13 at 16:08

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.