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(&$vars){
if ($vars['content']->type == 'mens-blog-post') {
array_unshift($vars['theme_hook_suggestions'], 'page__node__mens_blog_post');
}
if ($vars['content']->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.