(Tips) Customize Entire Page Template Based On Content Type

Tips : Customize Entire Page Template Based On Content Type

Today I needed to add a new candidate page.tpl file based on node-type. I found this code snippet and modified it slightly.

function phptemplate_preprocess(&$vars, $hook) {
switch ($hook){
case 'page':
// Add a content-type page template in second to last.	
if ('node' == arg(0)) {
$node_template = array_pop($vars['template_files']);
$vars['template_files'][]  = 'page-' . $vars['node']->type;
$vars['template_files'][]  = $node_template;
}
break;
}
return $vars;
}

| Read more

Courtesy : Tech.forumone.com