0

I have a strange situation where my Drupal 7 Omega 4 site appears to not be using a page.tpl.php template. The page renders and content appears but when I alter all of my page templates to indicate which one is in use (By adding a "<h1>TEMPLATE NAME.tpl.php</h1> above the "print render($page['content']);") I see nothing in the rendered output on screen.

I have cleared the caches. Many times.

Is it possible for Drupal to somehow not use a page template and still render a page's content? I would have thought not but can't figure out how this could be happening. I'm guessing I'm completely forgetting something quite basic here.

Any help greatly appreciated.

3

You can use the https://www.drupal.org/project/devel_themer module to see what tpl file is in use. You should see the path to your subtheme. If you see the path to the base theme, then your tpl file is not found.

  • Thanks for this tip. It worked a treat but showed up that for some reason my theme is using the Omega simple layout. I'll have to figure out why that's happening now :) – dibs Feb 22 '15 at 21:53
  • @dibs Go into the theme settings for your active theme, and select the Layouts tab. Uncheck "Enable layouts extension" and you should get your normal page template back. – mpdonadio Feb 22 '15 at 22:55
  • @MPD Strangely the layouts switch does nothing. I just get the omega simple layout either way. However once I use THEME_omega_layout_alter() I can control which layout I get. Something seems a bit odd but at least it's working for me now. – dibs Feb 22 '15 at 23:10
  • @dibs If you are loading theme settings from a file, you may need to update there. – mpdonadio Feb 23 '15 at 14:20
1

Check out Theme Developer. It will show you what templates are used on each renderable part of the page (page, block, node, etc.).

You could probably also implement hook_preprocess_page in your custom theme, and look at either $vars['theme_hook_suggestions'] or $vars['theme_hook_suggestion']. See this page about template suggestions.

1

There are quite a few variables that determine which template/function is used for any specific theme hook. There is a hierarchy of suggestions involved, where different patterns may take precedence. That general concept is outlined in the main theme documentation.

It's also important to note that if you are using a sub-theme (as is likely the case with a framework like Omega) your sub-theme's "page" template will take precedence over Omega's "page" template, which will also have precedence over core's own "page" template.

Because of all these precedence rules, you may have a case where there is a page template defined in your setup, which you have not "tagged" with your test <h1>TEMPLATE NAME.tpl.php</h1> text, that is being selected by specificity (perhaps it's targeting a content type, or path, or something more specific than the generic page templates you have already checked).

To see exactly which templates are used at any given time, you may want to check out the Theme Develper module, as it will provide a nice visual explanation of how Drupal's various theme hooks are related to DOM elements. Here's an example of the kind of output it can produce for the page-level container:

example theme developer output

  • Ha, it looks like a bunch of people posted simultaneously with essentially the same answer (use Theme Developer module). Anyway, I tried to add some additional notes in the answer above to explain some of the variables involved in the selection process. Maybe that will help others. – rjacobs Feb 23 '15 at 0:31

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.