Suggest a new template file for a page node view I have a site which has two main views, a men's blog and a women's blog, both with their own content types, mens-blog-post and womens-blog-post. The problem I am facing is that they share the same page--node.tpl file (node page view, default file:page.tpl not node.tpl), but need to have different content (e.g. other relevant views in the sidebar region). I need to suggest two new template files called page--node--mens-blog-post.tpl.php and page--node—womens-blog-post.tpl.php based on content type.

Here is my attempt:

function force_preprocess_page(&amp;$vars){
 if ($vars['content']-&gt;type == 'mens-blog-post') {
  array_unshift($vars['theme_hook_suggestions'], 'page__node__mens_blog_post');
 } 
 if ($vars['content']-&gt;type == 'womens-blog-post'){
  array_unshift($vars['theme_hook_suggestions'], 'page__node__womens_blog_post');
 } 
}


Can anyone help me clean this up and make it work? I am looking for any solution that works so I am open to other ideas.
To use a different template file for the node being shown, you need to add a new suggestion in $variables['theme_hook_suggestions'] (Drupal 7), or $variables['template_files'] (Drupal 6). In both the cases, the variable is an array.

In a module, the hook to implement is hook_preprocess_page().

function force_preprocess_page(&amp;$variables) {
  if (!empty($variables['node'])) {
    if ($variables['node']-&gt;type == 'mens-blog-post') {
      array_unshift($variables['theme_hook_suggestions'], 'page__node__mens_blog_post');
    }
    elseif ($variables['node']-&gt;type == 'womens-blog-post') {
      array_unshift($variables['theme_hook_suggestions'], 'page__node__mens_blog_post');
    }
  }
}


If you have a module called force.module, then your code is correct. The same code can be used for a theme whose short name is force; in this case, in its template.php file you add a force_preprocess_page() function.
In Drupal 6, your theme needs to also have the default template file (page.tpl.php), or the custom template is not going to be picked up. I didn't check if this is still valid in Drupal 7. (The only time I created a theme that was using a custom template file was in Drupal 6.)

I would rather check the variable $variables['node'] is not empty, as hook_preprocess_page() is called for every page served from Drupal, including the ones not associated with any node.