2

spending hours dealing with form_alter , finally realized that a tpl.php file is overriding the output !!!

now the question is

what are the ways to understand which template files(or functions) are affecting a display so they can be customized ?

2

They're called theme suggestions. Devel themer module shows all the suggestions in order, including tpl and theme functions, and which one was used, within the rendered page.

Note. It does this by modifying the DOM so it's good to switch it on when you need it then turn it off.

https://www.drupal.org/project/devel_themer

You'll also need the Devel module and simpledom API.

You can read more about the priority of suggestions here. https://www.drupal.org/node/1089656

As @Gulok mentions, as of Drupal 7.33 you can enable theme debugging in your settings file which puts the theme suggestions in to your HTML as comments. Just add $conf["theme_debug"] = TRUE; in your settings.php. Read more about that here https://www.drupal.org/node/223440#theme-debug

You can also get the theme suggestions in code and modify them, injecting your own suggestions, or completely replacing theme.

Get theme suggestions: https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_get_suggestions/7

| improve this answer | |
  • Any other issue on devel themer? if I turn it off then there wouldn't be any harmful affects remained? – Alireza Tabatabaeian Aug 8 '15 at 11:25
  • No. When it's off it does nothing. The UI is disabled. The injected HTML isn't injected. Nothing remains. – Queenvictoria Aug 8 '15 at 11:30
  • Update: This will not work with PHP 7. – Kevin Aug 1 '18 at 20:57
4

First, you can easily debug everything with Devel module. Another trick that I use to inspect what tpl is generating a particular element is by adding $conf['theme_debug'] = TRUE; in settings.php. After adding that refresh your page (or clear your cache first) then use inspect element. The tpl should be visible now in the HTML source. See the screenshot below.

enter image description here

Here is a blog that describe on how to theme a field.

Hoe that helps.

| improve this answer | |
0

rename the templates, or make backup and delete the file or part of the code (functions). Then refresh your page to see what gets affected.

| improve this answer | |
  • that doesn't look like a standard solution , and maybe the function is inside a module folder ... – Alireza Tabatabaeian Aug 8 '15 at 11:05
  • well if after deleting the tpl file you see nothing gets affected, then you can rule out the tpl file. – No Sssweat Aug 8 '15 at 11:13

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.