Skip to content

Instantly share code, notes, and snippets.

@macmladen
Created December 5, 2012 09:21
Show Gist options
  • Save macmladen/4214192 to your computer and use it in GitHub Desktop.
Save macmladen/4214192 to your computer and use it in GitHub Desktop.
Drupal sub-theming and inheritance

From: http://technobabble.drupalgardens.com/blog/creating-sub-theme-bartik

Choose a name for the theme (mine is Coolness) and create the sub-directory sites/all/ themes/coolness on your Drupal site.

Copy the bartik.info file to that directory and rename it to coolness.info

It's best to use the same directory structure as the base theme does for /css, /js, /templates, /color, and similar sub-directories.

Change or add the following to coolness.info:

name = Coolness description = A cool colored sub-theme for core's Bartik. core = 7.x base theme = bartik stylesheets[all][] = css/coolness.css

Create a stylesheet named coolness.css for your styles and style overrides and place it in the coolness directory

If using the Color module:

  • Copy the file /themes/bartik/css/colors.css to /sites/all/themes/coolness/css/colors.css.
  • Copy the folder and its contents /themes/bartik/color/ to /sites/all/themes/coolness/color/.

Drupal 7 follows specific rules of inheritance but you can override these as necessary.

  • All style sheets defined in the parent theme will be inherited, as long as you declare at least one stylesheet in your sub-theme's .info file.
  • All JavaScripts defined in the parent theme will be inherited.
  • Anything defined in the parent theme's template.php file will be inherited.
  • Any .tpl.php files from the parent theme will be inherited.
  • The parent theme's screen shot will be inherited but the parent theme's logo will not.
  • Sub-themes do not inherit custom regions from a parent theme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment