14

I am using Theme developer module for theming. The module is pretty good, but still it is very buggy. Is there a less buggy alternative?

28

Not really.

Since Drupal 7.33 release there is now simple support for alternative template support and themeing function alternatives listing in Drupal (core) by adding a setting in settings.php.

Added a "theme_hook_original" variable to templates and theme functions and an optional sitewide theme debug mode, to provide contextual information in the page's HTML to theme developers. The theme debug mode is based on the one used with Twig in Drupal 8 and can be accessed by setting the "theme_debug" variable to TRUE (API addition).

So in settings.php you set:

$conf['theme_debug'] = TRUE;

Then view the source of your page and you will see comments in your HTML as <!-- THEME DEBUG --> that list out function and template suggestions for the current Node.

Example Output for /admin/structure/views:

<!-- THEME DEBUG -->
<!-- CALL: theme('html') -->
<!-- FILE NAME SUGGESTIONS:
   * html--admin--structure--views.tpl.php
   * html--admin--structure.tpl.php
   * html--admin.tpl.php
   x html.tpl.php
-->
... lots of HTML ...
<!-- THEME DEBUG -->
<!-- CALL: theme('region') -->
<!-- FILE NAME SUGGESTIONS:
  * region--page-top.tpl.php
  x region.tpl.php
-->
<!-- THEME DEBUG -->
<!-- CALL: theme('toolbar') -->
<!-- BEGIN OUTPUT from 'modules/toolbar/toolbar.tpl.php' -->

This is a backport of Drupal 8 Twig helper functionality built into Drupal 8 (largely I guess because devel_theme has no Drupal 8 release).

| improve this answer | |
  • 3
    This should be the new way to templates infos when working on both D8 and D7. Also, enable the HTML comments display in firefox developer tools. – Kgaut Jul 23 '15 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.