Hello there,

I´ve removed the <?php print $title; ?> in my page tpl in Drupal 6. That way, I´m creating a special template for each nodetype, where I can set the title (or not) in my own way (it´s different for each content type). The thing is that with that action, I´ve also removed the title in node/add forms (wich is not good).

I´ve found here a solution of that problem´, so, I´ve added this function to a new module:

function modding_preprocess_page(&$vars, $hook) {
  if ((arg(0) == 'node') && (arg(1) == 'add')) {
    $vars['template_files'][] =  'node-add';
  }
}

That way, every time I did create a new node, the title would appear.

My node-add.tpl.php template looks like this:

<h1><?php print $title ?></h1>
<?php print $content ?>

My problem now is that the style sheets won´t load, and I don´t understand why. It looks as ugly as it can get when no style whatsoever is loaded. I may add that I´ve cleared cache more than once, and as this is a testing site, all performance caching has been disabled.

Please note that I´m telling you all this about my motivations, just in case you know a better solution to add the title to each node/add, node/edit form. Because I´m in a mess because of it.

Thanks for your help!

Comments

nevets’s picture

I would take a different approach.

Adding the title page to page.tpl.php but make it conditional, something like

if ( !empty($title) ) {
  print $title;
}

and then use hook_preprocess_page() to clear the title when viewing a node.

You could also use Display Suite which handles this.

Rosamunda’s picture

Gee, I like that! BIG THANKS!!!

Now it looks like this:

<?php 
  	if ((arg(0) == 'node') && (arg(1) == 'add') || (arg(2) == 'edit')){
	$node = node_load(array('nid' => arg(1)));
	print $title;
	}
?>

Yay! Thanks!

Rosamunda

nevets’s picture

You probably do not need

    $node = node_load(array('nid' => arg(1)));