Formatting pages with a certain node type
westley98 - August 12, 2008 - 00:53
Hi,
I am trying to insert an advertisement space into every page of a specific node type, say 'dummy'. I know if I create a page.tpl.php and name it page-dummy.tpl.php, it would reflect only mywebsite/dummy page. Is there a way to format all pages that display that certain node type? Thanks in advance.

Try this for drupal 5 (goes
Try this for drupal 5 (goes in your template.php file)
<?php
function _phptemplate_variables($hook, $vars) {
$vars = array();
if ($hook == 'page') {
// Add page template suggestions based on node type.
if (arg(0) == 'node' && is_numeric(arg(1))){
$node = node_load(array('nid' => arg(1)));
if($node->type == 'YOUR_NODE_TYPE'){
$suggestions[] = 'page-'. $node->type;
}
$vars['template_files'] = $suggestions;
}
}
return $vars;
}
?>
For drupal 6 you'll need to look at http://drupal.org/node/223430 as
_phptemplate_variableshas been depreciated.Ok I added that into my
Ok I added that into my template.php file. What is supposed to happen..? I'm using drupal 5.
For a node type of 'dummy'
For a node type of 'dummy' you should now be able to use page-dummy.tpl.php for all nodes of that content type.