Enable/disable template/block Hints Using MySQL

When doing front end development with Magento, there are many times when I want to turn on template/block hints for a one-page load. I don’t like having to wait on the Magento admin to load up the System > Configuration > Developer page, switch to Website view, and then turn on template/path hints. I have written a couple of MySQL snippets that allow me to enable/disable hints with one query.

I wrote the scripts so that for clean Magento installs, they will insert the necessary records into the core_config_data table. For Magento installs that have had the hints enabled/disabled, the record will already be present in the config table, so the script will just update that record.

Enable template/block hints for the first* website

-- Enable template hints
SET @template_hints = 1;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('websites','1','dev/debug/template_hints', @template_hints) ON DUPLICATE KEY UPDATE `value`=@template_hints;
-- Enable block hints
SET @template_hints_blocks = 1;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('websites','1','dev/debug/template_hints_blocks', @template_hints_blocks) ON DUPLICATE KEY UPDATE `value`=@template_hints_blocks;

Disable template/block hints for the first* website

-- Enable template hints
SET @template_hints = 0;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('websites','1','dev/debug/template_hints', @template_hints) ON DUPLICATE KEY UPDATE `value`=@template_hints;
-- Enable block hints
SET @template_hints_blocks = 0;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('websites','1','dev/debug/template_hints_blocks', @template_hints_blocks) ON DUPLICATE KEY UPDATE `value`=@template_hints_blocks;

As I covered in this post, it is possible to turn on hints at a global level, which activates hints for all website and for the admin panel. This is useful if you’re making customizations to the admin panel, or if you have multiple websites for which you’re wanting to activate/deactivate hints at the same time. The following two snippets modify hints at a global level:

Enable template/block hints for the admin panel and ALL websites

-- Enable template hints
SET @template_hints = 1;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('default','0','dev/debug/template_hints', @template_hints) ON DUPLICATE KEY UPDATE `value`=@template_hints;
-- Enable block hints
SET @template_hints_blocks = 1;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('default','0','dev/debug/template_hints_blocks', @template_hints_blocks) ON DUPLICATE KEY UPDATE `value`=@template_hints_blocks;

Disable template/block hints for the admin panel and ALL websites

-- Enable template hints
SET @template_hints = 0;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('default','0','dev/debug/template_hints', @template_hints) ON DUPLICATE KEY UPDATE `value`=@template_hints;
-- Enable block hints
SET @template_hints_blocks = 0;
INSERT INTO `core_config_data` ( `scope`, `scope_id`, `path`, `value`) VALUES ('default','0','dev/debug/template_hints_blocks', @template_hints_blocks) ON DUPLICATE KEY UPDATE `value`=@template_hints_blocks;

* If you have multiple websites, you’ll need to update the ‘1’ value set for the website field to reflect the ID of your website. If you have multiple websites, you can just turn on hints globally using the last two SQL snippets.

Share it

Topics

Related Posts

Google and Yahoo Have New Requirements for Email Senders

What ROAS Really Means

Everything You Need to Know About Updating to Google Analytics 4

Contact Us