Guy Lyons

Debugging Drupal 7 Templates

Jun 27, 2019

Drupal 7.33 introduced the ability to add helpful comments to your source code for better debugging of your templates. This is similar to how it now works in Drupal 8 with inspecting your Twig templates. I hadn’t known about this feature until quite recently, and since I still maintain some Drupal 7 sites, this feature is incredibly helpful when trying to debug a template.

Add this line to your settings.local.php and then clear cache.

$conf['theme_debug'] = TRUE;

Simple, I know, but after adding this, open you your inspector and give it a hard reload to see all the commented helpers inserted. The link below provides a much better detail of this setting.

Resources

Overriding Themable Output

Template Suggestions