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.

Comments

baronmunchowsen’s picture

Try this for drupal 5 (goes in your template.php file)

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_variables has been depreciated.

westley98’s picture

Ok I added that into my template.php file. What is supposed to happen..? I'm using drupal 5.

baronmunchowsen’s picture

For a node type of 'dummy' you should now be able to use page-dummy.tpl.php for all nodes of that content type.