0

Is there any way to know which theme hook or template is being used to output certain area of page? I am showing different menus on a page and i want to know which theme hook is being used to output particular menu and links of menu.

I tried dpm($variables) in function theme_menu_links($variables) in common.inc just to make sure if this theme hook is being used to output the links of menu but this theme hook is not being called and no output is printed. Then certainly this theme hook is overridden by other module or by theme.

Is it possible to know list of all available hooks and templates files for a particular are of a page like block, menu etc with the active theme hook used to output that area?

2

Yes, there is a module for that: Theme Developer.

Firebug for Drupal themeing

Note that this is a heavy module, enable it only when needed and on your local machine.

1

There is no single (active) hook to define an area (that's the idea of hooks). But there is one initial function defined by a module or theme and other modules and themes can alter the initial output.

If you have devel module installed, you can see the theme registry. This is a list of themable items with all files and (pre)process functions. So once a another hook alters an item it is listed there. Works great for entities, but I have never used it on menus. You can give it a try.

You'll find it at /devel/theme/registry

  • My mean by active hook is that the hook used to output that area at that time. As "Views" module show the active template along with all the possible templates to theme the style output and row style output under the view's "Theme: information" setting. – MutantMahesh Jan 17 '15 at 15:10
  • The template files as suggested by Views don't have much to do with hooks. There can be multiple hooks involved in preprocessing content, but it can (obviously) only be output in one template file. The active template is also visible in the theme registry. – Neograph734 Jan 17 '15 at 15:16

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.