无需 Web 界面即可在 Drupal 中切换主题

发布于 2024-07-22 04:32:14 字数 158 浏览 4 评论 0原文

我正在学习 php 和创建主题。

不幸的是,当我编辑当前在 drupal 中使用的主题时,我在主题中犯了一个错误,即使我点击 drupal/index.php,也不会再显示任何内容。 我想将损坏的 drupal 主题更改为可用的主题,但我无法这样做,因为我什至无法查看管理部分。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

终难遇 2024-07-29 04:32:14

Drupal.org 上的如何通过数据库重置主题页面提供了说明用于直接从 SQL 提示符更改主题。

目前尚不清楚这是否适用于最新版本的 Drupal,因此在尝试此操作之前备份您的数据库

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.

谎言 2024-07-29 04:32:14

更改前端主题的最简单方法是在站点/default/settings.php 中设置它:

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

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

$conf['theme_default'] = 'minelli';
手心的海 2024-07-29 04:32:14

在对当前问题进行排序方面,这里有一个简单的方法,应该可行......假设您当前的主题称为“custom_theme”。

  • 转到您的主题目录(可能是“sites/default/themes”)
  • 备份您的开发主题(即,将其移至其他地方,如果您使用 Linux 命令行,请执行类似“mv custom_theme custom_theme”的操作.bak")
  • 将花环主题复制到此处,并将其命名为与损坏的主题相同的名称(如果使用 LInux 命令行,类似这样的内容应该可以工作“cp -a ../../.. /themes/garland ./custom_theme"
  • 尝试立即查看您的网站。它现在应该使用花环而不是损坏的主题。

正如其他人之前所说,强烈建议您像以前一样为管理员使用不同的主题对于普通用户(如果你破坏了东西),选择一个安全的管理主题(如花环),然后如果你正在玩主题,你几乎总是可以进入管理界面。

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.

娇女薄笑 2024-07-29 04:32:14

或者,如果您使用的是 Drupal 6,删除/移动损坏的主题文件夹将使 Drupal 将主题更改为默认主题 (Garland)。

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

_失温 2024-07-29 04:32:14

也许并行使用两个主题会有所帮助。

为“用户前端”设置一个 - 您在 /admin/build/themes 中开发的一个,另一个标准,例如花环,您不会更改它,作为“管理后端” :/admin/settings/admin

如果您碰巧破坏了正在开发的主题,您只需转到管理区域(/admin),它就会切换回花环。

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.

南薇 2024-07-29 04:32:14

您还可以通过包含以下代码在主题中插入新的登录表单:

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

在损坏的主题的 page.tpl.php 文件中的任意位置,然后使用您的管理员凭据 进行注册;)

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 ;)

红ご颜醉 2024-07-29 04:32:14

另请参阅以下堆栈溢出问题。
它与它们相关

现在这是解决方案:
删除不良主题的文件并清除缓存。 清除缓存后即可再次登录。

主要困难是您必须在未登录的情况下清除缓存。

尝试中描述的清除缓存的方法之一
清除 Drupal 的缓存

如果没有则尝试这个:

如果您有 drush,则输入的命令将是

drush vset theme_default garland

或者在命令行上,或通过管理界面(例如 PHPMyAdmin)输入以下查询

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

然后:

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

请注意,'s:7' 指的是以下字符串的长度。 根据需要修改。 这是数据库手术,很棘手的事情。
或者
如果您使用的是每用户主题,并且您作为管理员刚刚把它搞砸了,请

UPDATE users SET theme='garland' WHERE uid = '1';

小心,因为其中任何一行错误都会将事情搞砸同样严重。

干杯!

穆达萨·阿里

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

彡翼 2024-07-29 04:32:14

据我所知,主题设置以及每个用户的主题设置都存储在数据库中。 删除主题的最快方法可能是将其从主题路径中删除。

只需将其移动到您的桌面上,Drupal 就应该能够检测到您请求的主题缺失,并将您指向默认主题。

更新:在我的 Drupal 5 安装上尝试过这个,结果是“干净”。 我建议将工作的 Drupal 主题复制到您的主题目录中(首先复制)。

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).

虐人心 2024-07-29 04:32:14

值得一提的是,如果您使用“Sections”模块将不同的主题应用到不同的部分站点,Drupal 站点上给出的说明不一定有效 - 您可能会发现将问题主题目录移开是正确查看管理界面的唯一方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文