I want to be able to print the contents of my node tpl up into the outer page region, accessible via the page.tpl.php (or an override). How exactly can I do this?

I originally thought about doing a variable_set in the node.tpl and then getting it in the page.tpl. However, if this would work, I would need to be able to create a template. I tried page--node--gallery-photo.tpl.php, but it doesn't seem to be the correct override.

What this the best way to do what I need to do here?

  • page.tpl.php already has the $node object? Am I missing something in your question? – Steven Oct 24 '13 at 16:19
  • I think I somehow missed that (still a little new with templates). I assume that is what I want. But the second question is now: is there a theme template suggestion which would specify pages with node type X, or would I just need do an if statement using the node type from $node? – user1015214 Oct 24 '13 at 16:29

If you are on Drupal 7 you can edit your theme's template.php and add (or edit) the function

function <YOUR_THEME_NAME>_preprocess_page(&$vars) { 
  if (isset($vars['node']->type)) { 
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type; 

The same task in Drupal 6 is accomplished by adding/editing in template.php

function <YOUR_THEME_NAME>_preprocess_page(&$variables) {
  if (isset($variables['node']->type)) {
    $variables['template_files'][] = "page-" . $variables['node']->type;

Then you can add page--<YOUR_CONTENT_TYPE_MACHINE_NAME>.tpl.php (or page-<YOUR_CONTENT_TYPE_MACHINE_NAME>.tpl.php in Drupal 6) to your theme. Remember to clear the theme cache.

| improve this answer | |

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.