I have a content type called “uprofile” and the template for this is in node-uprofile.tpl.php. in that content type I do not want to see the standard $title as used below in line 68 from my page.tpl.php

<?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>

how do I get Drupal to say ‘if this is a uprofile page do not print the $title’? but leave it active in all the rest?

many thanks

Comments

criz’s picture

hi, try something like:
if ($node->type != 'uprofile') print $title;

_______________________
Austrian Drupal Usergroup

________________________
Drupal Austria Association

henns20’s picture

shouldn't this be done in the node.tpl.php not the page.tpl.php-----and the code looks that was just submitted

henns20

gpk’s picture

In the default phptemplate, the heading (title) is output by the node.tpl.php iff there are multiple nodes being displayed on the page. Otherwise it is output by page.tpl.php.

gpk
----
www.alexoria.co.uk

mouse77e’s picture

just tried

<?php
if ($node->type != 'uprofile') {
print "";
} else {
if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif;
}
?>

... but it kills all titles... any ideas where i am going wrong?

mouse77e’s picture

only i just cant see it.... help pretty please

mouse77e’s picture

  <?php
		 if ($node->type != 'uprofile') {
		 print "";
		 } else {
		 if ($title)
		 {
		 print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';
		 }
		 }
		 ?>

tried to clean up the code but to no avail... the first if if ($node->type != 'uprofile') { seems to be the issue... if i add a value to the next line i.e. 'print "TEST";' it appears on all pages

gpk’s picture

Looks like 'uprofile' is not the right string to use there ... if you change your print "" to print "$node->type" you should see what is required. Then you should be able to use code like:

if ($title && $node->type != 'type'): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif;

Remember $node is only available to page.tpl.php if you are viewing a single node page.

gpk
----
www.alexoria.co.uk

mouse77e’s picture

Thanks mate but... still no joy...

gpk’s picture

What happens if you print node->type ?

Also note that the logic in the last code you posted was reversed, i.e. your code would omit the title for nodes *not* of type uprofile and print it only for nodes of type uprofile.

gpk
----
www.alexoria.co.uk

mouse77e’s picture

Also note that the logic in the last code you posted was reversed, i.e. your code would omit the title for nodes *not* of type uprofile and print it only for nodes of type uprofile.

sorry i just can't see what you are getting at (code blindness setting in)

gpk’s picture

         if ($node->type != 'uprofile') {
         print "";
         } else {
         if ($title)
         {
         print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';
         }
         }
         

This code is saying:
If node is not uprofile then print an empty string in place of the title, otherwise print the title (if it is not an empty string).

In other words, print the title if and only if the node is uprofile.

gpk
----
www.alexoria.co.uk

modul’s picture

Put the following styling code on top of your node-uprofile.tpl.php, and the title will be there still, but it won't be displayed.

<STYLE type="text/css">
  H2 {display:none}
</STYLE>

if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif;

Obviously, this rules out the use of h2 markups in other parts of your node-uprofile texts, possibly also in sidebars, but if you can live with that limitation, or if you use different styling for your sidebars, this approach easily does the trick.

Ludo

mariapaz’s picture

Thank you for the info, I managed to remove h2 titles changing the code at line 68 page.tpl.php (garland theme).

 if ($title){
         	if ($node->type != 'name_of_content_type'){
	 print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';
}}; 

Hope it helps

clevername’s picture

This module allows you to omit titles from certain node types, amongst other things: http://drupal.org/project/nodeformsettings