Summary

This chapter described how to install and create Drupal themes. It covered a lot of ground, and I will briefly summarize the main points here.

The theming system that governs the look and feel of your Drupal site is built on themable functions—functions in the core modules and includes that are responsible for generating HTML output. The HTML that is produced by these fundamental functions is adequate to run a site and ready to be styled using CSS. Themes are groups of files organized by folders in the themes directory that represent alterations and enhancements to the core themable functions and the HTML they generate.

Administrators can decide which of the themes available in the themes directory are activated. If more than one theme is activated, users will be able to choose which theme is to be used for them when they visit the site.

Various strategies have been developed for managing the interactions between themes and the underlying themable functions. As a result, various theme engines are available. PHPTemplate is the standard engine and is part of the standard Drupal download.

Most of the work done in designing the look of a Drupal web site will be achieved using CSS and binary image files. Every theme has a style.css file, which can be customized to make themes unique. Other style sheets can be added using the function theme_add_style.

Themable functions from the core include files and modules can be overridden by adding new functions that follow a naming convention that combines the name of the active theme with the name of the themable function. For PHPTemplate-driven themes, these new functions are placed in the theme's template.php file. Theme overrides can also be achieved in the form of tpl.php template files, a strategy that has many advantages for designers and site administrators.

The most common themable functions have been overridden by PHPTemplate automatically. These functions include theme_page, theme_box, theme_block, theme_comment, and theme_node. Any PHPTemplate-driven theme must provide, at a minimum, an override for theme_page. This is done by including a page.tpl.php file in the theme's directory. If other tpl.php files for these common functions are found in the same directory, they are used instead of the underlying themable function.

The node.tpl.php template, which overrides the function theme_node, can have node-type specific variants, which follow a naming convention. The file node-blog.tpl.php, for example, will provide an override that is specific to blog nodes. Any node type can be themed in this way.

You can create style sheet-only themes (styles) by making a subdirectory in a theme and adding a style.css file to it. The theme will rely on the tpl.php templates and theme overrides from the parent directory, but the style.css file in the subdirectory will be used.

Several modules can assist you in various theming tasks or augment the theming system in some way. With so many tools, you usually have several ways to achieve any particular goal concerning the appearance of your web site.

In the next chapter, I will describe some of Drupal's features regarding hosting and maintaining sites. This will include how to set up multisite hosting, schedule cron tasks, use different backup strategies, and get help and find resources on Drupal.org.

CHAPTER 6

0 0

Post a comment