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.
<?php if (!$node->type == 'forum'): ?>
<div id="sidebar"><?php print $sidebar; ?></div>
<?php endif; ?>
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->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->type == 'forum') {
$vars['is_forum'] = TRUE;
}