3

For some reason the Theme developer module doesn't work on my site (whenever i activate it and navigate on my site it just shows a white page with written "Jump to main content"), but all I want to know is which TPL files are being used to render my current page.

I know that if i put print_r($variables["theme_hook_suggestions"]); in preprocess_html or preprocess_page functions (or any other preprocess function for what it matters) I'll be able to see the suggestions for the html.tpl.php and page.tpl.php files respectively, but i actually need to go deeper and see all the template suggestions that are being checked to render the current page.

Is there any way to do this without using the Theme developer module?

  • Do you mean the module 'theme developer'? If so, the white screen can be caused by an out of memory exception. The module needs a lot of memory – Robin Oct 30 '14 at 19:50
  • @valepu: You should check your logs why you have WSOD. Or ask why Devel Themer generates one. – kenorb Oct 30 '14 at 21:05
3

In addition to the function/template specific hooks, there's also hook_preprocess():

This hook allows modules to preprocess theme variables for theme templates. It is called for all theme hooks implemented as templates, but not for theme hooks implemented as functions.

Combine that with the Devel module's dpm() function and you should get what you need:

function MYTHEME_preprocess(&$vars, $hook) {
  if (!empty($vars['theme_hook_suggestions'])) {
    dpm(t('Hook - @hook', array('@hook' => $hook)));
    dpm($vars['theme_hook_suggestions']);
  }
}
10

You can put this in your settings.php $conf['theme_debug'] = true;

This outputs html comments on your page which will help you with debugging how the theme suggestions are selected.

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.