Magento : Enable And Disable Template Path Hints In Admin Panel

The below custom php script in magento explains how to enable and disable template path hints in admin panel programatically.

1) You can enable admin path hints directly through phpmyadmin also if you have database access by executing following sql statement.

INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`, `value`)
       VALUES ('websites', '0', 'dev/debug/template_hints', '1');
OR

1) You can use custom PHP script explained below to enable and disable path hints in admin.

<?php
define('MAGENTO_ROOT', getcwd());
require_once MAGENTO_ROOT . '/app/Mage.php';
umask(0);
Mage::app();

$writeAdapter = Mage::getSingleton('core/resource')->getConnection('core_write');
$readAdapter = Mage::getSingleton('core/resource')->getConnection('core_read');

$valueToEnableTemplateHints = 1; // set it to 0 to disable template hints on frontend
$valueToEnableTemplateBlockHints = 1; // set it to 0 to disable block template hints on frontend

//To enable path hints on frontend

$query = "SELECT config_id FROM `core_config_data` WHERE `path` LIKE '%dev/debug/template_hints%'";
$results = $readAdapter->fetchCol($query);
if (empty($results)) {
$writeAdapter->query("INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('websites', 0, 'dev/debug/template_hints', $valueToEnableTemplateHints),
('websites', 0, 'dev/debug/template_hints_blocks', $valueToEnableTemplateBlockHints)");
echo 'Path hints enabled';
} else {
//echo 'Already path hints value exists';
$query = "SELECT config_id FROM `core_config_data` WHERE `path` LIKE '%dev/debug/template_hints%'";
$results = $readAdapter->fetchCol($query);
if (count($results)) {
foreach ($results as $result) {
$writeAdapter->update(
"core_config_data",
array("value" => 1),
"config_id=$result"
);
}
}
}

//To disable path hints on frontend

$query = "SELECT config_id FROM `core_config_data` WHERE `path` LIKE '%dev/debug/template_hints%'";
$results = $readAdapter->fetchCol($query);
if (count($results)) {
foreach ($results as $result) {
$writeAdapter->update(
"core_config_data",
array("value" => 0),
"config_id=$result"
);
}
}
?>
Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s