Switching themes in Drupal without the web interfa

2020-07-18 08:24发布

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.

9条回答
狗以群分
2楼-- · 2020-07-18 09:13

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

$conf['theme_default'] = 'minelli';
查看更多
ら.Afraid
3楼-- · 2020-07-18 09:13

Please also see the following stack over flow issue. it is related to them

Now here is solution : 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 Clearing Drupal's cache

IF Not then Try this one :

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;
TRUNCATE cache_bootstrap;
TRUNCATE cache_block;

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.

Cheers!

Mudassar Ali

查看更多
小情绪 Triste *
4楼-- · 2020-07-18 09:13

As far as I know, theme settings are stored in the database, as well for each individual user. The quickest way to get rid of a theme is probably removing it from the theme path.

Just move it onto your desktop and Drupal should be able to detect that your requested theme is missing and point you to the default instead.

Update: Tried this on my Drupal 5 installation, it turned out 'clean'. I suggest copying a working Drupal theme into your theme directory (make a copy first).

查看更多
淡お忘
5楼-- · 2020-07-18 09:14

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

查看更多
小情绪 Triste *
6楼-- · 2020-07-18 09:15

It's worth mentioning that if you're using the "Sections" module to apply different themes to different parts of the site, the instructions given on the Drupal site won't necessarily work — you may find that moving the problem theme directory out of the way is the only method of seeing the admin interface properly.

查看更多
做个烂人
7楼-- · 2020-07-18 09:22

Maybe using two themes in parallel will help.

Set one for the "user frontend" - the one you are developing at /admin/build/themes, another one standard, like garland, which you are NOT going to change, as a "administration backend": /admin/settings/admin.

If you happen to break the theme you're developing, you just go to the admin area (/admin), it will switch back to garland.

查看更多
登录 后发表回答