Theme Options
COLORS SKINS PAGE COLOR BACKGROUND BODY

Creating a Sub Theme in Drupal 7

Creating a sub-theme is really very simple. A sub-theme inherits a lot of the design resources from its parent theme. We can have multiple sub-themes inheriting only one base theme.

It is important to know that what a sub-theme inherits from its parent theme.

A sub theme will inherit:

  • All style sheets
  • Template files
  • Functions and overrides defined in the template.php

A sub-theme will not inherit:

  • Logos and Favicons
  • Block regions
  • Advanced theme settings

Creating a sub theme

  1. Theme Directory: Create a directory in your custom theme directory in the same way you create a theme. Give it a name. For example: mysubtheme.
  2. .info file: Create an .info file in the directory mysubtheme as similar to the parent theme. The only difference will be the following line:
    base theme = theme_name<
  3. Logo: Add the logo in the sub-theme directory.
  4. Screenshot: Theme screenshot is inherited from the base’s theme. To override the same, just create a new screenshot.png in the sub theme directory.
  5. Style Sheets:  You must declare at least one stylesheet in your sub-theme for any of the parent theme's stylesheets to be inherited. To override any particular css file (for instance,  style.css), add the following line in your .info file and add a new css file with the same name in your sub-theme’s directory.
    stylesheets[all][] = style.css
  6. Javascripts: All the js files defined in the parent theme will be inherited. To override any particular js file, add the following line in your .info file and add a new js file (for instance, script.js), with the same name in your sub-theme’s directory.
    scripts[] = script.js
  7. Regions:  You can declare a new set of regions in the sub-theme. To inherit the custom regions of the parent theme, the regions should be copied in the sub-theme’s .info file.
  8. Template Files: You can add any template files in your sub theme. If the template file is found in your sub-theme’s directory, then Drupal will override the parent’s template files. Otherwise, it will use the parent’s template files.
  9. Images: The images used in the theme can also be copied in the sub theme directory. If the image is found in your sub-theme’s directory then Drupal will override the parent theme’s image with the same name. Otherwise, it will use the parent’s image.

Comments (0)

The content of this field is kept private and will not be shown publicly.