About the Reviewer

Dave Myburgh started out in computers when entire operating systems ran on a single floppy disk and 640kb of RAM was a lot He studied to become a molecular biologist, but never lost his passion for computers. Later, he ran a successful computer company for a couple of years in South Africa, before moving to Canada with his wife. He went back to science on his arrival in Canada, and since discovering Drupal almost two years ago, he has once again started his own company, MybesInformatik. He...

How to Name Your Overrides

Phptemplate System Override

At run time, Drupal is designed to seek out overrides to themeable functions before applying the default functions. The system does this by looking for files in the following order (assuming your site employs the PHPTemplate engine) 1. themename_functionname (e.g., garland_breadcrumb) 2. themeengine_functionname (e.g., phptemplate_breadcrumb) 3. theme_functionname (e.g., theme_breadcrumb) The naming convention is the key and must be followed scrupulously, because the name establishes the order...

Theme Set Up and Configuration

The large and active community of developers that has formed around Drupal guarantees a steady flow of themes for this popular CMS. The diversity of that community also assures that there will be a wide variety of themes produced. Add into the equation the existence of a growing number of commercial and open source web designs and you can be certain that somewhere out there is a design that is close to what you want. The issue becomes identifying the sources of themes and designs, and...

Two Contrasting Examples

As you can probably see, PHPTemplate presents a number of options that can be used to support the creation of themes. You can almost literally do as much or as little as you like. A look at the range of techniques used by the themes in the market shows a wide variety of approaches to theming. Some themes, like the Gagarin theme we installed in Chapter 2, take a very elemental approach and implement only the bare minimum. Other themes, like the default theme Garland, are more complex, and...

The Advanced Search Form

Clicking on the advanced search link on the Page Search Form brings the user to the Advanced Search Form, which includes a number of new options for searching the site. More options appear here and more formatting issues. The Advanced Search orm appears in the content region. More options appear here and more formatting issues. The Advanced Search orm appears in the content region. The Advanced Search Form is produced by the function search_form, working in conjunction with the code in the node...

Create Dummy Content

Temporary dummy content allows us to see text on the screen as we make our changes, and helps us to judge more easily our fonts, colors, spacing, and margins. First, let's create a new Page. Name it About Us and throw in a few lines of placeholder text. Next, create a couple of Blog entries with dummy text. Finally, let's add a new Forum. To do this, access the Forums option under Content Management. You will see there a message advising you that you need to create a new forum in order to...

CSS in Zen Tao

The creation of a sub-theme a theme within a theme, if you will is made possible by the way Drupal works with themes. The system allows you to create multiple themes based on the same set of underlying files through the use of an additional CSS file placed within a subdirectory. The same approach used here in Zen and Tao , is employed in the default Garland theme, which includes the sub-theme Minelli, and in the default theme Chameleon, which includes the sub-theme Marvin. The CSS files of our...

What is PHPTemplate

PHPTemplate is one of a family of applications known as templating engines referred to frequently in Drupal and in this text as theme engines . These applications serve a middleware function and determine the coding syntax, which will be used to create the theme. As the name implies, PHPTemplate supports the popular PHP programming language for theme creation. PHPTemplate was built by developer Adrian Rossouw, and was created specifically for use with Drupal. PHPTemplate is the most widely...

Formatting the Sidebars and Footer

The Left Sidebar is unused in this theme, but the Right Sidebar Region is essential, as it contains the main navigation and several Blocks. The way the CSS is written, the style definitions for Left and Right Sidebar are combined we'll maintain that sidebar-ieft .biock, sidebar-right .biock padding-bottom 15px margin-bottom 20px I want to control the styling of the menu in the Right Sidebar our Navigation menu , so I will add the following border-top 1px soiid 676734 padding-top 10px...

Set User Access

We now need to set the user permissions so that our site visitors can see and use the various functionalities we've set up. Go to the User management section and open the Access control manager. Select the following for anonymous user access Access site-wide contact form Save your new permissions and let's move on to the next step in our preliminary preparations.

Alternative Theme Engines

At the time of writing, the release of Drupal 5.x was only briefly past. Developers of the various templating engines were still working to port their applications to Drupal. While the 4.x series sports a number of templating engine options, including the popular Smarty engine and XTemplate, Drupal 5.x users were left with only one alternative to the default theme engine. Engines that are compatible with the 4.x series are not compatible for the 5.x series. While at this time only one...

Sidebar Right

This snippet places the blocks designated for the right Region into a table cell. Note the conditional statement this allows the output to be hidden in the event that no blocks are assigned to the Region. For styling, the table cell td is given an id named to reflect the placement sidebar-right . if show_blocks amp amp empty blocks_right output . lt td Note that the official Drupal site provides an alternative syntax Q for inserting Regions into your pure PHP theme. See http www.drupal.org node...

Set Up Menus

For this theme, we're going to run the Primary Links at the top of the page. We'll set the menu named Navigation as our Main Nav on the right-hand side of the page. We'll also create a Footer Nav and place that at the bottom of the page. Access the Menu manager, under Site building, and make the changes outlined below. For the Primary Links, we will need to set up the following note that the Weight settings, which affect the ordering, are completely up to you these are simply suggestions the...

The Poll Module Forms

Poll Drupal

The Poll module involves several forms. The two we will deal with here are the Poll Block Form and the Poll Page Form. How the functional units will be grouped within the structure of the page . tpl. php file. How the functional units will be grouped within the structure of the page . tpl. php file. Drupal provides several themeable functions that affect the Poll module. Unlike the bare-bones themeable functions provided for the Search Forms, the functions for the Poll module give you a great...

Cloning a Theme

Let's get started by making a copy of the Zen theme. We'll keep the original and work on the copy. I recommend you always employ this approach to cloning themes by preserving the integrity of the original, you have a reference and you maintain the ability to roll back your changes in the event a serious problem arises. Cloning a theme is a simple matter. First, make a copy of the original theme and place the copied directories in the sites all themes directory. Next, rename the directory with...

Look at Our New Theme

With the completion of the styie .css file, the new theme is ready for use. here Is the nv lon statement this Is the StDQBfl Iben ore currently 1 l and 0 srursis online, This is iths ntn theme - 'HluaWater - In adk gt n. The loo is minimalist u the content of the theme ts the bare minimum In terms of functionality and styling. The thorn a is pur CSS ami uses the barn minimum In Styling. The theme Is dependent on PHPTeropUte end supports the defeuft P FTeroplat option , like I09D, sLtfl s 09 n,...

Intercepting Template Files

Up to this point, we have limited the discussion to how to handle overriding primary template files and individual functions however, in Drupal, you can extend the intercept and override concept further to achieve highly granular control of the page templates that are called in various situations. You can, in other words, intercept and override entire page files on a conditional basis. For example, if you wish to have different templates used for different types of content, you can create...

Adding HTML via Function Attributes

The Drupal form API makes provisions for you to be able to add basic HTML to a form via a limited set of attributes named prefix, suffix, and markup. These attributes are invoked from inside the function accordingly, this approach to modifying forms is used most frequently by developers when they create the form. prefix is used to add HTML before a form element. suffix is used to add HTML after an element. markup allows you to declare HTML as type markup in the form. This approach is generally...

The Block Search Form

The Block Search Form is often visually similar to the Theme Search Form, but the key point to note here is that this is controlled by the search module and must be assigned to a block position. Like other blocks, a title can also be specified by the administrator via the Block manager. The Block Search Form often visually differs from the Theme Search Form in only one regard the presence of the block title in the default Garland implementation, above, Search . The Block Search Form is produced...

Set Block Visibility

The only thing left at this stage is to configure the Block visibility in a common sense 1. Display the User login Block on the home page only 2. Hide the Button ad Block on the administrator pages 3. Display the Recent blog posts Block throughout the Forum posts First the User login Block. Go to the Blocks Manager and click the Configure link on the User Login block. Change the Page specific visibility settings to the second option, Show on only the listed pages. In the Pages text box enter lt...

PHP XTemplate

PHP XTemplate was once the default templating engine in Drupal but has fallen by the wayside as development of the application slowed. For many users, XTemplate was a popular system. It separates the HTML from the PHP and makes it easy for designers to work with themes. Also, as it is written in PHP and can handle either PHP4 or PHP5, it tends to perform well with Drupal. Unfortunately, at this stage, it seems unlikely to be making a comeback in the near future, and those of you who previously...

Setting Up the Workspace

There are several software tools that can make your work of modifying themes more efficient. Though no specific tools are required to work with Drupal themes, there are a couple of applications that you might want to consider adding to your tool kit. I work with Firefox as my primary browser, principally due to the fact that I can add into Firefox various extensions that make my life easier. As mentioned in the previous chapter, installing the Web Developer extension is hugely helpful when...