I'd like to provide the ability to open some content in a new window without all of the headers and sidebars of the normal content window. I tried to do this with a preprocessor, and got close, but still no cigar:

function THEME_preprocess_page(&$vars) {  
  if (isset($_GET['popup']) && $_GET['popup'] == '1') {
    //error_log( var_export( $vars['theme_hook_suggestions'], true ) );
    // returns as last array item: page__node__3
    $vars['theme_hook_suggestions'][] = 'page__node__3__popup';

I then have a template with the file name: page--node--3--popup.tpl.php which is just a straight copy of the region--content.tpl.php file, and it actually does hit that template! The problem is that only the title shows up - and when I clear the cache I get a warning message that content is undefined in my popup template. I've also tried naming the file and setting the theme_hook_suggestions to 'region--content--popup'/'region_content_popup' with the same results.

Here is the content of region--content--popup.tpl.php

<div<?php print $attributes; ?>>
  <div<?php print $content_attributes; ?>>
    <a id="main-content"></a>
    <?php if ($title): ?>
    <?php if ($title_hidden): ?><div class="element-invisible"><?php endif; ?>
    <?php print render($title_prefix); ?>
    <h1 class="title" id="page-title"><?php print $title; ?></h1>
    <?php print render($title_suffix); ?>
    <?php if ($title_hidden): ?></div><?php endif; ?>
    <?php endif; ?>
    <?php if ($tabs): ?><div class="tabs clearfix"><?php print render($tabs); ?></div><?php endif; ?>
    <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
    <?php print $content; ?>
    <?php if ($feed_icons): ?><div class="feed-icon clearfix"><?php print $feed_icons; ?></div><?php endif; ?>

The H1 page title appears and nothing else.

  • Can you put the content of page__node__3_popup?
    – Gnuget
    Commented Nov 7, 2013 at 7:00
  • question updated with content of the template.
    – cmcnulty
    Commented Nov 7, 2013 at 13:16

1 Answer 1


You probably want:

print render($page['content']);

You can find the variables available to you in the template by printing get_defined_vars() using print_r(), core's debug() function, or one of the extremely handy devel module debugging functions such as kpr() or dpm().

I'd install devel and do this:


Your modal method might not play nicely with page cache so I'd definitely test to make sure it fits your usecase.

  • Thank you, using $page['content'] did the trick. The mystery to me is when $content is populated and when it's not. Thanks for the pointers for debug options. Ignorant of the 'drupal way', I've been using good old error_log(var_export($arg,true)).
    – cmcnulty
    Commented Nov 8, 2013 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.