Last updated October 29, 2012. Created by john.lawson on November 20, 2008.
Edited by kay_v, mariolina, maryannking, Tor Arne Thune. Log in to edit this page.
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.
Write Secure Code
Any PHP functions in your theme should use the Drupal API and follow best practices for writing secure code. Note that functions should be placed in template.php or a module and not in *.tpl.php.
Deploy Your Theme Selectively
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 Theming Modules:
Use the Switchtheme module and allow only certain roles to switch themes.
The Sections module allows you to apply a theme to one or more sections of your site, rather than to the entire site. This capability is especially useful if you are theming for a very large site because it makes it possible to deploy your theme in stages.
Use Drupal's Multi-site Feature:
You can use Drupal's Multi-site capability to set up a live test site alongside your existing site.
Turn Off PHP Error Reporting
When PHP encounters an error, it can generate an error log and display a report on the screen. While these error messages can be helpful in debugging your site, they can be a security risk on a live site as they may reveal information about your server that can be used to compromise it.
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.
Use a Stable Administrative Theme During Development
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 in defining which pages should render with the admin theme, try the Administration theme module.
All core themes support all admin pages, so it's a safe bet to assign either Garland or Blue Marine (or Stark if using Drupal 7) as the admin theme. Go to the Administration theme section on the Appearance page (Administration > Appearance, or http://example.com/admin/appearance) and change Administration theme to Stark. In Drupal 6, go to the Administration theme page (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 if you are using a separate admin theme that is stable. The one page where this is not possible is the Block configuration page for your theme. Because blocks can be configured on a per-theme basis, 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 make it possible to target this page with unique styles, which is one way to selectively theme this page.