1

I currently have an Omega subtheme located as a subdirectory of the .../sites/all/themes/omega. I think this location was a requirement for Drupal 6. Now that we're on Drupal 7, I'm looking for the best practice on where this subtheme should be located. Does it make sense to add it to .../sites/all/modules/custom/ or maybe create a new directory like .../sites/all/modules/themes/.

Any best practice advice would be great.

Thanks

4 Answers 4

3

Themes should be stored in sites/all/themes, not sites/all/modules.

You could certainly add your custom theme to sites/all/themes/custom, but what I do is just add my custom theme(s) to sites/all/themes directly. I do this because I name my custom themes for the sites I am working on, so it's very clear that the particular theme is specific to the site.

The other reason I don't think a /custom directory is necessary is because, unlike modules, one generally only has five or six themes (at most) installed on a single site. So there is far less possibility for confusion.

1

I prefer to keep sites/all/ for themes and modules I get from drupal.org, and place custom themes and modules under sites/default/themes and sites/default/modules, directly. I do this so that the custom work is in the same place as the public files and the settings file. By keeping everything together, I only need to worry about a single tree, sites/default/, when moving between servers.

Drupal 7 Module Development says (pg 28) says that this is the current best practice, but I have never see this cross-referenced to official docs on drupal.org.

0

The best practice is: don't leave them in /themes. Whether you use /sites/all/themes or /sites/mysite.com/themes only matter for multisite codebases: /sites/all will be shared, while /sites/mysite.com will be site-specific. This means that @MPD's approach is useful, since contributed modules and themes should be shared (with shared and contributed patches). But keep in mind that updating a module in /sites/all will require running database updates on every site!

0

Sub-themes are not required to be in a sub-directory of the parent theme, in Drupal 6 and higher. Drupal 6 introduced the "base theme" property that should be used in the .info file of the child theme.

Creating a sub-theme says:

The sub-theme to-be should be located in its own directory. Prior to Drupal 6, this directory had to be a subdirectory of its base theme; in Drupal 6 and 7 it can be placed outside of the base theme's directory.

To declare your theme to be a sub-theme of another, it is necessary to alter the sub-theme's .info file. Add the following line to the sub-theme's .info to declare its parent or "base theme." Change "themeName" to the internal name of the parent theme (that is, the name of the parent theme's .info file, usually all lower case).

base theme = themeName

As per the directory where to put a theme, these are the directories where Drupal looks for a theme:

  • profiles/$profile/themes
  • sites/all/themes
  • $config/themes

$profile is the machine name of the currently used profile, and $config is the directory containing the settings.php file currently used. The subdirectories of those directory are also checked, which means (for example) that sites/all/themes/custom/bluecheese could be used to contain a theme.
In any case, the modules directory is not checked, if it is not a sub-directory of one of the directories I listed before. I would rather avoid mixing modules and themes, or using "modules" as name of a directory containing a theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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