无需 Web 界面即可在 Drupal 中切换主题
我正在学习 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
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.
更改前端主题的最简单方法是在站点/default/settings.php 中设置它:
The easiest way to change your frontend theme is to set it in your sites/default/settings.php:
在对当前问题进行排序方面,这里有一个简单的方法,应该可行......假设您当前的主题称为“custom_theme”。
sites/default/themes
”)mv custom_theme custom_theme”的操作.bak
")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".
sites/default/themes
" probably)mv custom_theme custom_theme.bak
")cp -a ../../../themes/garland ./custom_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.
或者,如果您使用的是 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).
也许并行使用两个主题会有所帮助。
为“用户前端”设置一个 - 您在
/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.您还可以通过包含以下代码在主题中插入新的登录表单:
在损坏的主题的
page.tpl.php
文件中的任意位置,然后使用您的管理员凭据
进行注册;)you can also insert a new login form in your theme by including this code:
anywhere in the
page.tpl.php
file of your broken theme, then register with youradmin credentials
;)另请参阅以下堆栈溢出问题。
它与它们相关
现在这是解决方案:
删除不良主题的文件并清除缓存。 清除缓存后即可再次登录。
主要困难是您必须在未登录的情况下清除缓存。
尝试中描述的清除缓存的方法之一
清除 Drupal 的缓存
如果没有则尝试这个:
如果您有 drush,则输入的命令将是
或者在命令行上,或通过管理界面(例如 PHPMyAdmin)输入以下查询
然后:
请注意,'s:7' 指的是以下字符串的长度。 根据需要修改。 这是数据库手术,很棘手的事情。
或者
如果您使用的是每用户主题,并且您作为管理员刚刚把它搞砸了,请
小心,因为其中任何一行错误都会将事情搞砸同样严重。
干杯!
穆达萨·阿里
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
Either on the commandline, or via an administration interface (eg PHPMyAdmin) enter the following query
Then either:
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
Be careful, as getting either of those lines wrong can mess things up just as badly.
Cheers!
Mudassar Ali
据我所知,主题设置以及每个用户的主题设置都存储在数据库中。 删除主题的最快方法可能是将其从主题路径中删除。
只需将其移动到您的桌面上,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).
值得一提的是,如果您使用“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.