Drupal 6 Theming Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a fresh look using the color module

The color module allows the administrator to easily change the color scheme of themes that support it. This facilitates a fresh look for the site without having to create a new theme or sub-theme. Drupal's default theme, Garland, supports the color module and, in this recipe, we will be covering the steps required to change its color scheme to something unique.

Getting ready

Ensure that the color module is enabled in admin/build/modules (Home | Administer | Build | Modules). Since we are going to change the color scheme of the Garland theme, ensure that it is set as the current theme.

How to do it...

Colorizing the Garland theme can be accomplished by following these steps:

  1. Navigate to admin/build/themes (Home | Administer | Build | Themes).
  2. Look for the Garland theme and click on the configure link next to it.
  3. Look for the section titled Color scheme.
  4. In this section, the Color set drop-down lists available presets. Choosing any of the presets will change the color scheme of the preview section further below.
    How to do it...
  5. Once satisfied, click on the Save configuration button at the bottom of the page to save our changes.

How it works...

The color module works by generating stylesheets using the new color scheme which effectively replace the existing stylesheet during runtime. The generated CSS file is stored in the site's files directory in a folder named color. In addition to the stylesheets, the color module, when configured correctly as with the Garland theme, can also blend the theme's image assets to suit the new color scheme.

Note

The color module creates a new stylesheet which is a customized copy of the theme's original CSS file. Since it is a copy, fixes and updates to the original file are not automatically propagated to it. Therefore, whenever changes are made to the original file, It is recommended that the stylesheet be regenerated by simply saving the customized color settings once again.

There's more...

We are not restricted to the inbuilt presets provided by the color module and can also create our own.

Custom presets

If the provided presets are unsatisfactory, clicking on the textfields below the drop-down will allow further customization. Once a textfield has focus, the color wheel on the right can also be clicked and used to select different palettes at will. These new settings are saved as the Custom preset as demonstrated in the following screenshot:

Custom presets