The base Zen theme is designed to be easily extended by its sub-themes. You shouldn't modify any of the CSS or PHP files in the
zen/ folder; but instead you should create a sub-theme of zen which is located in a folder outside of the root
zen/ folder. The examples below assume zen and your sub-theme will be installed in
sites/all/themes/, but any valid theme directory is acceptable (read the sites/default/default.settings.php for more info.)
IMPORTANT NOTE: In Drupal 7, the theme system caches which template files and which theme functions should be called. This means that if you add a new theme, preprocess or process function to your template.php file or add a new template (.tpl.php) file to your sub-theme, you will need to rebuild the "theme registry." See http://drupal.org/node/173880#theme-registry
Drupal 7 also stores a cache of the data in .info files. If you modify any lines in your sub-theme's .info file, you MUST refresh Drupal 7's cache by simply visiting the Appearance page at admin/appearance.
This documentation is specifically for people who use Drush. You can take advantage of the
drush zen command to automatically generate a sub-theme.
- Ensure drush knows about the zen command
After you have downloaded Zen and placed it in your sites/all/themes directory, you need to enable the Zen theme and clear Drupal’s (and Drush’s) cache so that it will notice the Zen drush command. Type:
drush en zenfollowed by
drush cc all
- Run the drush zen command with the following parameters.
In the command line, use the
drush zen "Foo theme" foocommand to generate a subtheme with machine name
fooand human name "Foo theme" in your Drupal site.
You may provide additional options to specify parts of your theme before it's created.
- Set your website's default theme.
Log in as an administrator on your Drupal site, go to the Appearance page at admin/appearance and click the "Enable and set default" link next to your new sub-theme.
- Modify the markup in Zen core's template files.
If you decide you want to modify any of the .tpl.php template files in the zen folder, copy them to your sub-theme's folder before making any changes. And then rebuild the theme registry.
For example, copy zen/templates/page.tpl.php to foo/templates/page.tpl.php.
- Modify the markup in Drupal's search form.
Copy the search-block-form.tpl.php template file from the
modules/search/folder and place it in your sub-theme's template folder. Don't forget to rebuild the theme registry.
You can find a full list of Drupal templates that you can override in the templates/README.txt file or http://drupal.org/node/190815
Why? In Drupal 7 theming, if you want to modify a template included by a module, you should copy the template file from the module's directory to your sub-theme's template directory and then rebuild the theme registry. See the Drupal 7 Theme Guide for more info.
- Further extend your sub-theme.
Here's the output of drush help zen:
Create a theme using Zen.
Create a sub-theme, using the default options:
drush zen "My theme name"
Create a sub-theme with a specific machine name:
drush zen "My theme name" my_theme
Create a sub-theme in the specified directory without RTL stylesheets:
drush zen "My theme" --without-rtl --path=sites/default/themes
name A name for your theme.
machine_name [optional] A machine-readable name for your theme.
--description A description of your theme.
--machine-name [a-z, 0-9] A machine-readable name for your theme.
--name A name for your theme.
--path The path where your theme will be created. Defaults to: sites/all/themes
--without-rtl Remove all RTL stylesheets.