How do I determine a page's content type for non-node pages? I’m trying to modify my theme’s page.tpl.php to not show certain regions when I’m displaying content from the core forum module.

&lt;?php if (!$node-&gt;type == 'forum'): ?&gt;
&lt;div id="sidebar"&gt;&lt;?php print $sidebar; ?&gt;&lt;/div&gt;
&lt;?php endif; ?&gt;


This works fine when I display actual forum nodes, but not when I show pages with the forum listings (/forum, /forum/1, etc.), since those pages aren't actually nodes. 

How can I determine if a page will be a certain content type, so I can use conditional statements in page.tpl.php?

Edit: Some quick clarification. Working with $node-&gt;type is easy for pages that actually use nodes. However, when working with Views, or in the case of the forum module, the content is not node-based (it is called with forum-topic-list.tpl.php and $node is null). Because of this, it's impossible to programmatically determine if the page is really a forum (since it's not really a node). I'm trying to figure out a way around that.

Edit 2: Possible (kludgy?) solution: Putting this in theme_preprocess_page works. Is it the best way to do it though?

// Determine if page is a forum
$node = $vars['node'];
$template = $vars['template_files'][0];

if ($template == 'page-forum' || $node-&gt;type == 'forum') {
    $vars['is_forum'] = TRUE;
}
Use template_preprocess() for detecting node on page and pass additional variable as flag to template file, like:

$variables['display_region'] = TRUE;


Maybe Panels can help you too.