- Open the admin control panel
- Open the system tab and select configuration
- Select Main Website or Name of your website (NOT DEFAULT CONFIG) from the Current Configuration Scope drop down
- Select Developer on the left sidebar
- Open the Debug drop down
- Set Template Path Hints To Yes
- Click on Save Config to save down your changes
When developing themes for the front-end Magento has included an easy way to show you which file you need to edit: Template Path Hints (enable it via System > Configuration > Developer > Debug > Template Path Hints = only visible when changing to website or store scope)
Unfortunately the same trick doesn’t work when developing for the back-end. This Quick Tip shows you how can have the same hints for the back-end.
Simply paste the following into
app/code/core/Mage/Adminhtml/Block/Template.php
public
function
fetchView(
$fileName
)
{
Varien_Profiler::start(
$fileName
);
extract (
$this
->_viewVars);
$do
=
$this
->getDirectOutput();
if
(!
$do
) {
ob_start();
}
echo
'<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;"><div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial; text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'" title="'
.
$fileName
.
'">'
.
$fileName
.
'</div>'
;
$thisClass
= get_class(
$this
);
echo
'<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial; text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'" title="'
.
$thisClass
.
'">'
.
$thisClass
.
'</div>'
;
try
{
include
$this
->_viewDir . DS .
$fileName
;
}
catch
(Exception
$e
) {
ob_get_clean();
throw
$e
;
}
echo
'</div>'
;
if
(!
$do
) {
$html
= ob_get_clean();
}
else
{
$html
=
''
;
}
Varien_Profiler::stop(
$fileName
);
return
$html
;
}
before the last closing brace }.
Just be sure to remove the code again then you are finished. If there is enough demand for it I might package the change up into a new MageBase extension.
Update: Thanks to Olivier’s comment I have quickly bundled up a separate extension so no core edits are required – simply download and unpack into your Magento root folder. A cache refresh is required. Then choosing Template Path Hints is available in the default scope – enabling it will show comments in the back-end as well as front-end.
Just be sure to remove the code again then you are finished. If there is enough demand for it I might package the change up into a new MageBase extension.
Update: Thanks to Olivier’s comment I have quickly bundled up a separate extension so no core edits are required – simply download and unpack into your Magento root folder. A cache refresh is required. Then choosing Template Path Hints is available in the default scope – enabling it will show comments in the back-end as well as front-end.