Blog

Enable/disable template/block Hints Using MySQL

When doing frontend development with Magento, there are many times when I want to turn on template/block hints for just 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.

Posted on January 8, 2010

Posted by Erik Hansen

Add comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.