Last Updated: May 03, 2017
·
1.516K
· joecochran

Magento template hints through a query string.

Template path hints are a huge help when debugging an issue with Magento. That being said, it can be tedious to jump into the admin panel to switch this constantly. This will allow you to toggle it with a query string. Change the following code in /app/code/core/Mage/Core/Block/Template.php at line 192:

ORIGINAL

public function getShowTemplateHints()
{
    if (is_null(self::$_showTemplateHints)) {
        self::$_showTemplateHints = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS)
            && Mage::helper('core')->isDevAllowed();
        self::$_showTemplateHintsBlocks = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS)
            && Mage::helper('core')->isDevAllowed();
    }
    return self::$_showTemplateHints;
}

NEW:

public function getShowTemplateHints()
{
    if (is_null(self::$_showTemplateHints)) {
        self::$_showTemplateHints = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS)
            && Mage::helper('core')->isDevAllowed();
        self::$_showTemplateHintsBlocks = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS)
            && Mage::helper('core')->isDevAllowed();
    }
    $debug = Mage::app()->getRequest()->getParam('debug', false);
    if ($debug == 'yes') {
      self::$_showTemplateHints = true;
      self::$_showTemplateHintsBlocks = true;
    }
    return self::$_showTemplateHints;
}

Now, when we are looking at http://example.com/checkout/onepage/ and we need to see hints, we would just add ?debug=yes to the end of our url to make it http://example.com/checkout/onepage/?debug=yes

I wouldn't recommending committing this to your production environment, but adding it to your development env can save a LOT of time.

1 Response
Add your response

It's certainly a useful tips. Have you considered rewriting the block inside a module instead? And maybe take Mage::helper('core')->isDevAllowed() and Mage::getIsDeveloperMode() into consideration when setting self::$_showTemplateHints and self::$_showTemplateHintsBlocks?

over 1 year ago ·