Unusable theme - How To reset your theme via the database

Last modified: August 7, 2009 - 23:50

Situation:
Either you have installed or modified a theme that just breaks everything, or you've deleted the current theme without disabling it first.

As you've now learned, you should have switched out of the theme via administration before destroying it, because you are left with nothing or almost nothing as a UI to work with now.

But we can probably recover.

If you see some content but no navigation blocks
We can fix up the themes by going directly to the required pages.

  1. You'll have to be logged on, so enter http://example.com/?q=user in the browser. Logon as normal. (use your own Drupal path of course)
  2. Enter http://example.com/?q=admin/build/themes (D5) or http://example.com/?q=admin/themes (D4) to see a version of the themes page. Select a valid theme (eg BlueMarine) and things should be in a state where you can continue.

If you see no content at all, maybe garbage or a totally blank screen or the above doesn't work...
We need to do surgery on the database.
It's easier if you choose a theme name that you know used to work, eg 'garland' or 'bluemarine' for D4.

Either on the commandline, or via an administration interface (eg PHPMyAdmin) enter the following query

UPDATE system SET status=1 WHERE name = 'garland';

Then either:
UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
TRUNCATE cache;

Note that 's:7' refers to the length of the following string. Modify as needed. This is database surgery, tricky stuff.
OR
If you are using per-user themes, and you've just messed it up for yourself as admin, try
UPDATE users SET theme='garland' WHERE uid = '1';

Be careful, as getting either of those lines wrong can mess things up just as badly.

If you see some of the theme, but no navigation blocks, you may be able to proceed as in the first case, described above.

That didn't work
It's hard to guess how badly your system is damaged at this point. Did you delete the phptemplate directory?
Try re-uploading the entire contents of the /themes directory from a clean distribution of the exact same version of Drupal.

See Also:
Disabling Modules via phpMyAdmin
Download a fresh copy of a missing or corrupted module/image/file

Linux Folder Permissions

The White Screen of Death occurred while installing the Zen theme for Drupal 5. Renaming the folder from zen to zen-base, and then nothing worked - white screen. Renaming the folder back to zen allowed got the site working again. The solution came from reading this issue: http://drupal.org/node/222934

The problem was complicated by the fact that after unzipping the zen files into the theme directory (fedora linux), but forgetting to set (chown -R) the owner and group of the directory and files it contains to the right users. The theme still shows up in the admin section, but if enabled and it and the directory and files belong to users without permissions, you also have problems with white screens.

It was trying to fix this, without realizing that the owner and group were wrong, followed by renaming the folder, that compounded the problem.

 
 

Drupal is a registered trademark of Dries Buytaert.