Drupal Theme Function and Template Discovery

By

This article was published in the print magazine Drupal Watchdog, Volume 2 Issue 1, 2012-03, on page 8, by Tag1 Publishing. The magazine was distributed at Drupalcon Denver, 2012-03-19. The article was also published on their website.

If you have multiple layers of overridable theme functions and templates, it can become difficult to determine which ones are determining the formatting of any given element on the page. Fortunately, you can use the Theme developer module, which places on every page a "Themer info" dialog, with a checkbox.

Themer info dialog
Figure 1. Themer info dialog

After activating it, when you hover over any element, a red border appears. If you click the element, you are shown the functions and templates that created it, and the names you could select from to override that functionality, as well as the function arguments.

Article field themer info
Figure 2. Article field themer info

Copyright © 2012 Michael J. Ross. All rights reserved.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <address> <area> <blockquote> <br> <cite> <code> <dd> <div> <dl> <dt> <em> <fieldset> <h1> <h2> <h3> <h4> <h5> <h6> <hr> <img> <input> <li> <map> <ol> <p> <pre> <span> <strong> <sup> <u> <ul>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.