Safe theme development

You will invariably run into problems when developing a theme. Here are some safeguards and considerations when resolving issues with your theme.

Always Develop on a Test Site

To prevent users seeing a website full of bugs, you need a test site. The best alternative is to set up a local server and install Drupal on your localhost.

Selectively Deploy Your Theme

When your theme is ready to show to other people but not ready to go live, you can use several methods to selectively show only certain users your theme.

By Role:
Configure the permissions for a role to allow users to select their own theme via their user account settings. This is perhaps the most straightforward method and requires no additional modules.

Use Modules:
Use the Switchtheme module and allow only certain roles to switch theme.
The Sections module allows you to apply a theme to one or more sections of your site, useful for a staged deployment if you have a very large site.

Use a Multi-site:
You can use Drupals Multi-site capability to set up a live test site alongside your existing site.

PHP Error Reporting

When PHP encounters an error, it can generate an error log and display a report on screen. While these error messages can be helpful to debug your site, it can be a security risk on a live site as this may reveal information about your server that can be used to compromise your server.

PHP allows you to turn off error reporting using the php.ini file. Preconfigured LAMP installations such as Wampserver allow you to toggle error reporting on and off without having to manually edit the php.ini file.

Administrative Theme

Many themes are not suitable for your administration area, in particular narrow fixed width themes. Drupal allows you to select a separate theme just for the admin pages. If you need additional flexibility defining which pages should render with the admin theme, try the Administration theme module.

All core themes support all admin pages, so its a safe bet to assign either Garland or Blue Marine (or Stark if using Drupal 7) as the admin theme. Go to Administer > Site configuration > Administration theme and change <system default> to Garland.

Even if your own theme breaks during development you will still be able to access the vast majority of your admin pages. The one page where this is not possible is the Block configuration page for your theme. Because blocks can be configured per theme, Drupal loads up that particular theme. If your theme does not display this page well, you will need to work on it.

Themes such as Zen, Genesis and many others have body class CSS selectors that allow to target this page with unique styles, which is one way of selectively theming this page.

 
 

Drupal is a registered trademark of Dries Buytaert.