I haven't been able to find the answer or at least know how to do it.
I have a content type called 'news' and I want it to use a different template than page.tpl.
I am using the theme celju.
In its template.php it has the following:
--------------
* Different Node Templates by Node Variables (nid, type, view)
* http://chapterthreellc.com/blog/zirafa/different_node_templates_node_var...
*/
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'node':
if ($vars['page']) {
$vars['template_files'] = array('node-default-page', 'node-'. $vars['node']->type .'-page', 'node-'. $vars['node']->nid .'-page');
}
else {
$vars['template_files'] = array('node-'. $vars['node']->nid);
}
break;
}
return $vars;
}
--------------
Do I need to change something in the above code to get the content type "news" to use a different template than page.tpl?
If not what do I need to do? Thanks.
Comments
Could this be a subtheme
Could this be a subtheme problem not reading the right .tpl?
Figured it out. In the celju template.php add this:
function phptemplate_preprocess_page(&$variables) {
// IF THIS IS NOT WORKING BE SURE TO CLEAR THE THEME REGISTRY.
// FAILURE TO DO SO WILL NOT ALLOW THIS FUNCTION TO BE CALLED.
if($node = menu_get_object()) {
$variables['node'] = $node;
$suggestions = array();
$template_filename = 'page';
$template_filename = $template_filename . '-' . $variables['node']->type;
$suggestions[] = $template_filename;
$variables['template_files'] = $suggestions;
}
}
Take out:
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'node':
if ($vars['page']) {
$vars['template_files'] = array('node-default-page', 'node-'. $vars['node']->type .'-page', 'node-'. $vars['node']->nid .'-page');
}
else {
$vars['template_files'] = array('node-'. $vars['node']->nid);
}
break;
}
return $vars;
}