Community Documentation

Unusable theme - How To reset your theme

Last updated January 8, 2013. Created by LeeHunter on December 14, 2007.
Edited by hansrossel, dman, Shai, m1mic. Log in to edit this page.

Situation:

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

  • Check you have installed the theme in /sites/all/themes
  • Check if the Linux ownership of the theme files is correct
  • Check if you have installed the necessary base theme if required by the theme

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/appearance (D7) or http://example.com/?q=admin/build/themes (D5/6) to see a version of the themes page. Select a valid theme and things should be in a state where you can continue.

If you see no content at all, maybe errors or a totally blank screen and you cannot login anymore.

Method 1

Remove the files of the bad theme and clear the cache. After clearing the cache you will be able to login again.

The main difficulty is that you have to clear the cache without being logged in.

Try one of the methods for clearing the cache described in http://drupal.org/node/42055.

Method 2: Change the active theme with Drush or in the database

If you have drush, the command to type would be
drush vset theme_default garland

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.

Comments

Clear Theme Registry Cache

One thing that can exacerbate the situation is the theme_registry value in the cache table. I my case I was working on a theme and had moved files, but this setting was holding on to the old location of files and not finding them. Also the variables row can have an effect as well. They can both be emptied fro the database manually rather than trying empty the cache from the Performance admin. These rows did not seem to be affected either that way or by running cron. Only when emptying them directly did the changes reflect immediately.

Drush helps here

I read this page: http://drupal.org/node/530780

Comment #24 shows a simple way to set the default theme and the admin theme from the command line / terminal window / SSH using drush.

List themes: drush pm-list --type=theme
List enabled themes : drush pm-list --type=theme --status=enabled
Set the default theme: drush vset theme_default
Set the admin theme: drush vset admin_theme

Thanks

I know it's been quite some time since you posted this but I just wanted to say thanks for adding this in this post. I'm loving drush more and more everyday and at least pat myself on the back a little for installing it and getting familiar when others said they weren't ready for it. Thanks again I need that 2 sec fix.

works in Drupal 7

Confirmation that

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

Then just had to disable the themes i had enabled then enable my original site theme and set as default

This is really stupid

It is really, really stupid that one has to go into MySQL to recover a corrupted or bad theme. Is there a bug or a feature request trying to change this in D6 or D7? Maybe have a theme override in settings.php or be able to have a fall-back if you rename the theme in sites/all/themes or something that doesn't require you backing up your entire database in case you make a mistake?

Low Tech Solution

Rename your non-working theme folder. Copy a simple, working default theme folder to your all/themes folder next to your non-working them folder and give it the original name of your non-working theme. Delete the default theme's .info file and copy over the one from your non-working theme. Go to your site. Drupal should now launch the default theme copy in place of your non-working theme and give you enough functionality to set your theme to something other than your non-working theme in the theme admin panel.

Devin

this works

thank you Devin, your solution worked for me. Now i know that before performing a major update, one should.. a) Put the site in maintenance mode; b) Take a full backup; c) Disable all non-core modules; d) Set your theme to Garland (this is what I didn't do. and got into trouble).

SKBando

Yep.

"Low Tech" or KISS ... whatever; it WORKS. Good post, devin1492 :-)

Thanks delvin1492

Brilliant! That sneaky trick saved me!

drupalshrek
Maintainer of the VChess module visible in use at chess website Chesspos.com

thank you...it works :)

thank you...it works :)

Great tip - thanks!

Devin1492, this was a really helpful tip. Thanks!

This worked for me

Thanks devin1492. Got me out of a mess and only thing that seemed to help.

I used a copy of the Bartik theme (using Drupal 7).

However I knew there wasn't much wrong with the theme that crashed the site (tried it on another), but it just wouldn't load on the one that crashed. Managed to log in and reset cache (and all the other tips) and everything, but no joy.

Anyway, I found (accidentally) that if I disabled the theme and then enabled it before setting it as default, something (presumably in the database) got fixed.

This latter, extra step may help some folks. . .

Problem with resetting theme

After making adjustments to the Bartik theme, the site shows up in a theme without background & without admin bar and there is no way to reach the admin settings
Tried to remove the adjusted theme and cleared the caches (update.php and clear.php) but doesn't give any result

Following notice comes up
Notice: Undefined index: highlighted in include() (regel 126 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_first in include() (regel 138 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_second in include() (regel 144 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: bartik_marc in drupal_theme_initialize() (regel 100 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in _drupal_theme_initialize() (regel 145 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in _theme_load_registry() (regel 334 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Undefined index: bartik_marc in theme_get_setting() (regel 1414 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in theme_get_setting() (regel 1461 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).

any idea how to get back to a working drupal?
using Drupal v7.17

Marc N.

If either of your

If either of your default/admin themes work, you can grab the blob from that record (admin_theme or theme_default) and paste it in the breaking value's blob.

mySQL error

I somehow got rid of the main contents block on a theme, and now absolutely no content is showing on any pages, including the admin pages. I'm trying to reset the theme using this method but I run into this mySQL error:

#1146 - Table 'webibek7_SMFDdr.system' doesn't exist

That table definitely exists!

Any ideas or does any one have another reset for my particular issue?

Thanks!

admin theme

Thanks for this!
I also had an instance where the admin theme was set to the same broken thing as the normal theme.

In that case you can add this query to your list:
UPDATE variable SET value='s:7:"garland"' WHERE name = 'admin_theme';

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x, Drupal 6.x, Drupal 7.x
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.