How Drupal Finds Themes

Whenever you visit the theme administration page (admin/themes), Drupal looks to see which themes are available and lists them for you. This is a four-step process, which is important to be aware of if you are interested in modifying existing themes or making new themes:

1. Drupal looks for pure themes like Chameleon by searching for subdirectories of themes that contain a name .theme file. It expects that the name of the theme will match the directory in which it is found, so chameleon.theme should be found in the themes/chameleon folder, for example. Each pure theme is added to the list of themes.

2. Drupal determines which engines are available by looking for files with the .engine suffix in subdirectories of the themes/engines directory. These engines are given the responsibility of determining which templates fall under their control. A list of theme engines is made.

3. Drupal asks each engine to identify themes belonging to it. PHPTemplate accomplishes this by looking for subdirectories of themes that have a page.tpl.php file in them. The presence of this file is the only requirement of a PHPTemplate theme, and you could conceivably make a theme with nothing but page.tpl.php. Each theme engine then returns a list of themes under its control, and these are added to the list of themes.

4. Finally, there are CSS-only themes, called styles, which consist of nothing but a style sheet that is applied to an existing template or theme. For this, Drupal looks for files called style.css in subdirectories of known themes. Each style.css that is found behaves as an alternate style sheet that is applied to the HTML of the parent theme (in whose folder it resides). The list of styles is then added to the list of themes, which is now complete.

Table 5-1 shows the makeup of the default themes.

Table 5-1. Components of the Core Themes

Theme

Engine

Templates

CSS

Bluemarine

phptemplate.engine

*.tpl.php

themes/bluemarine/style.css

Pushbutton

themes/pushbutton/styles.css

Chameleon

chameleon.theme

chameleon.theme

themes/chameleon/style.css

Marvin

themes/chameleon/marvin/style.css

Figure 5-5 shows all of the theme-related files that are delivered with Drupal and their relationships based on Table 5-1. You will notice how the Marvin style exists as a subdirectory in the Chameleon theme and consists of only a style sheet. This figure also shows the default *.tpl.php template files in the phptemplate directory. These templates affect all PHPTemplate themes, unless they are specifically overridden within the themes themselves. Details on overriding templates and creating CSS-only themes (styles) are provided in the "Customizing Themes" section later in this chapter.

Marvin Style

□ Gft bluemarine

[fj bloc! .tpl.php [fj bo ■ .tpl.php [¡}) corninent.tp'l.php [fj node, tpl.php [fi page.tpl.php P, style.ess - icj chameleon

[¡}) chameleon, the me' P, ccmmcn.css P, style.ess

- G-r phptemplate ipl block.tpl.php [PS box.tpl.php ipl comment.tpl.php ipl default.tpl.php [PI node.tpl.php [PI phptemplate.engine pushbutton [?S block, tpl.php [?S box. tpl.php [?S comment, tpl.php [?S node, tpl.php Pj page.tpl.php P. style.ess

Bluemarine Theme

Chameleon Theme

Default Templates

PHPTemplate Engine

Pushbutton Theme

Figure 5-5. Directory structure of the core themes

0 0

Post a comment