Friday, April 20, 2012

Template/Block Hints in Admin Panel

Magento’s admin panel uses the exact same design pattern as the front end ( blocks/layouts/templates).If you have done any modification at admin side and you need to turn on template/block hints for the admin panel,you need to do following steps as there is not built in support from magento.

step 1:
Go to Magento Database

step 2: Turn on

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

Now,you can check at admin panel for template/block hints.

step 3: Turn off

To turn off hints,delete above record from the table or if you are thinking to turn on it again then simply update its value field from 1 to 0.

Logic behind this is:
 /app/code/core/Mage/Core/Block/Template.php

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


The “Mage::getStoreConfig” method checks for config values that are set in the current scope (ie, default, website, store, store view). In the admin panel, only values set in the “Default Scope” are loaded.

Magento only allows you to turn on hints when you’re in the configuration scope of a Website or Store View. This means that when the code above tries to load the configuration, it returns “null” because that config value isn’t set in the “Default Config” scope. Running the MySQL query above adds the hint config values to the “Default Config” scope. Here is a screenshot showing the settings for turning on the hints – notice that the “Main Website” configuration scope is selected.




No comments:

Post a Comment

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...