php 在管理页面中启用模板路径提示 - Magento
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4373481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable template path hint in admin pages - Magento
提问by Damodaran
I want to enable template path hints in admin panel. I know how to do it for the front end, but for back end?? I actually want to edit the admin panel .
我想在管理面板中启用模板路径提示。我知道如何为前端做到这一点,但对于后端呢??我实际上想编辑管理面板。
Thanks in advance..
提前致谢..
回答by clockworkgeek
You can do it by changing the database directly. If you have something like phpMyAdmin that is a good way to gain access. Enter this SQL.
您可以通过直接更改数据库来实现。如果您有像 phpMyAdmin 这样的东西,这是获得访问权限的好方法。输入此 SQL。
INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`, `value`)
VALUES ('websites', '0', 'dev/debug/template_hints', '1');
When you are done with path hints just delete the matching record from core_config_data
Or update the value
field to 0
instead of deleting the whole record, it will probably be the last one since you've just added it.
完成路径提示后,只需删除匹配的记录core_config_data
或将value
字段更新为0
而不是删除整个记录,它可能是您刚刚添加后的最后一个。
回答by f0xdx
You can enable template and block path hints in every store (including the admin store) by setting them in the Magento configuration. To do this, simply edit your module's configuration file config.xml
(which gets injected into Magento's global configuration).
您可以通过在 Magento 配置中设置模板和块路径提示在每个商店(包括管理商店)中启用它们。为此,只需编辑模块的配置文件config.xml
(它会被注入到 Magento 的全局配置中)。
To enable template and block path hints in the admin area add this to your config.xml
file
要在管理区域中启用模板和块路径提示,请将其添加到您的config.xml
文件中
<config>
...
<stores>
<admin>
<dev>
<debug>
<template_hints>1</template_hints>
<template_hints_blocks>1</template_hints_blocks>
</debug>
</dev>
</admin>
</stores>
</config>
To disable path hints simply change to 0, or delete the node.
要禁用路径提示,只需更改为 0,或删除节点。
回答by BenRoe
open /app/etc/local.xml and add the follow code
打开 /app/etc/local.xml 并添加以下代码
<config>
...
<websites>
<admin>
<dev>
<debug>
<template_hints>1</template_hints>
<template_hints_blocks>1</template_hints_blocks>
</debug>
</dev>
</admin>
</websites>
</config>
回答by Alan Storm
The feature wasn't designed to be used on the admin. Its system config is explicitly set to only allow you to se this at the website or store level, not the global level.
该功能并非旨在用于管理员。它的系统配置明确设置为仅允许您在网站或商店级别进行设置,而不是全局级别。
Assuming this is just for work in a development environment, the approach I'd take would be to override the class
假设这仅适用于在开发环境中的工作,我将采用的方法是覆盖该类
Mage_Core_Block_Template
and override (with a class alias override, or a local/Mage replacement) the getShowTemplateHints
method hints.
并覆盖(使用类别名覆盖,或本地/法师替换)getShowTemplateHints
方法提示。
public function getShowTemplateHints()
{
//return false
return true;
}
// old method, here for demo purposes only. Don't hack the core
// public function getShowTemplateHints()
// {
// if (is_null(self::$_showTemplateHints)) {
// self::$_showTemplateHints = Mage::getStoreConfig('dev/debug/template_hints')
// && Mage::helper('core')->isDevAllowed();
// self::$_showTemplateHintsBlocks = Mage::getStoreConfig('dev/debug/template_hints_blocks')
// && Mage::helper('core')->isDevAllowed();
// }
// return self::$_showTemplateHints;
// }
You can then manually change getShowTemplateHints to return true or false if you want the feature on or off, or add whatever additional logic you wanted.
然后,您可以手动更改 getShowTemplateHints 以返回 true 或 false,如果您想要打开或关闭该功能,或者添加您想要的任何其他逻辑。
I would not recommend you push this change to the production server.
我不建议您将此更改推送到生产服务器。
回答by Ovidiu
I know it's late but you can do it easily this way:
Just change settings in the configuration file www/app/code/core/Mage/Core/etc/system.xml
我知道为时已晚,但您可以通过这种方式轻松完成:只需更改配置文件中的设置 www/app/code/core/Mage/Core/etc/system.xml
Set sections>dev>debug>fields>template_hints>show_in_default
to 1
and
set sections>dev>debug>fields>template_hints_blocks>show_in_default
to 1
too
设置sections>dev>debug>fields>template_hints>show_in_default
于1
和设置sections>dev>debug>fields>template_hints_blocks>show_in_default
到1
太
回答by MagePsycho
You can use the following extension in order to enable the template path hints for frontend & backend easily & securly in a joomla way:
http://www.magepsycho.com/easy-template-path-hints.html
您可以使用以下扩展以 joomla 方式轻松安全地启用前端和后端的模板路径提示:http:
//www.magepsycho.com/easy-template-path-hints.html
回答by Saurabh Verma
A quite handy solution: Modify getShowTemplateHints()
function defined in \app\code\core\Mage\Adminhtml\Block\Template.php file as below:
一个非常方便的解决方案:修改getShowTemplateHints()
\app\code\core\Mage\Adminhtml\Block\Template.php 文件中定义的函数如下:
To run below function: In your browser type, http://www.mymagentosite.com/?th=1&token=PHP
要运行以下功能:在您的浏览器类型中,http://www.mymagentosite.com/?th =1&token=PHP
You can see template hints and added Block Names.
您可以看到模板提示和添加的块名称。
public function getShowTemplateHints()
{
if (is_null(self::$_showTemplateHints))
{
self::$_showTemplateHints = Mage::getStoreConfig('dev/debug/template_hints')
&& Mage::helper('core')->isDevAllowed();
self::$_showTemplateHintsBlocks = Mage::getStoreConfig('dev/debug/template_hints_blocks')
&& Mage::helper('core')->isDevAllowed();
}
// overwrite the template hint [SPECIALLY FOR SHOWING TEMPLATE PATH HINTS IN ADMIN]
$th = Mage::app()->getRequest()->getParam('th', false);
$token = Mage::app()->getRequest()->getParam('token', false);
if($th == 1 && $token == 'PHP'){
self::$_showTemplateHints = true; // for template path
self::$_showTemplateHintsBlocks = true; // block names
}
return self::$_showTemplateHints;
}
回答by Hardik
Go to your Database and Just run this query:
转到您的数据库并运行此查询:
INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);
To disable them again, run this query:
要再次禁用它们,请运行以下查询:
UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
To enable again run this query:
要再次启用运行此查询:
UPDATE core_config_data set value = 1 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
回答by Phuc
I don't think you should make it too difficult, let 's make it easy by easy steps. You can look at the instruction here about How to turn on template path hints in Magento
我不认为你应该让它太难,让我们通过简单的步骤让它变得容易。您可以在此处查看有关如何在 Magento 中打开模板路径提示的说明