Switching themes in Drupal without the web interface

22,621

Solution 1

The How To reset your theme via the database page on Drupal.org has instructions for changing your theme directly from the SQL prompt.

It's not immediately clear whether this will work in the most recent version of Drupal, so back up your database before attempting this.

Solution 2

The easiest way to change your frontend theme is to set it in your sites/default/settings.php:

$conf['theme_default'] = 'minelli';

Solution 3

In terms of sorting your current problem, here's a simple way to do it that should work... Let's say your current theme is called "custom_theme".

  • Go to your theme directory ("sites/default/themes" probably)
  • Backup your development theme (i.e. move it elsewhere, if you're using Linux command line do something like "mv custom_theme custom_theme.bak")
  • Copy the garland theme to here and name it the same as your broken theme (if using LInux command line, something like this should work "cp -a ../../../themes/garland ./custom_theme"
  • Try viewing your site now. It should now use garland instead of your broken theme.

As others have said before, it's also highly recommended that you use a different theme for admins as you do for normal users (in case you break stuff). Select a safe admin theme (like garland) and then you can nearly always get to the admin interface if you're playing with theming.

Solution 4

Or if you are using Drupal 6, removing/moving the broken theme folder will make Drupal change the theme to the default theme (Garland).

Solution 5

you can also insert a new login form in your theme by including this code:

 `<?php 
    if(!user_is_logged_in() ){
        print drupal_render(drupal_get_form('user_login'));
    }else{
        print "You are already logged in!";
   }?>` 

anywhere in the page.tpl.php file of your broken theme, then register with your admin credentials ;)

Share:
22,621
burnt1ce
Author by

burnt1ce

Updated on January 17, 2020

Comments

  • burnt1ce
    burnt1ce over 4 years

    I'm in the process of learning php and creating themes.

    Unfortunately, while I was editing a theme that i was currently using in drupal, I made a mistake in the theme such that nothing shows up anymore, even if i were to hit drupal/index.php. I want to change my broken drupal theme to a working one but i'm unable to do so because I can't even view the administration section.

  • burnt1ce
    burnt1ce almost 15 years
    I did what you say and I get the following drupal error: rwtsang_2 is the name of the theme. warning: include(./themes/rwtsang_2/@rwtsang_2/page.tpl.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\drupal\includes\theme.inc on line 1011. warning: include() [function.include]: Failed opening './themes/rwtsang_2/@rwtsang_2/page.tpl.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\drupal\includes\theme.inc on line 1011.
  • Andrioid
    Andrioid almost 15 years
    Weird, I'd swear I've done this myself during my template experiments. Are you sure that the theme is gone from all parts of the Drupal instlalation? This includes /sites/ and /themes. The other options are replacing the directory with a copy of the default drupal theme or going into the SQL database and change your theme settings from there.
  • htoip
    htoip about 12 years
    drush vset theme_default garland is the simplest way on that page.