Hiding page titles for specific node types in Drupal 6

By shane
Tue, 2011-07-12 10:39
comments

Share with Others

Occasionally you may need to hide a page title in Drupal 6 for a number of reasons. This can be especially useful if you are theming a node page and want to display the page title somewhere else in the node content. I often need to use this when theming Ubercart product pages. It is really very simple to do, just add this function to your template.php file inside your theme.

function THEMENAME_preprocess_page(&$vars) {
  $vars['original_title'] = $vars['title'];
  if (!empty($vars['node']) && in_array($vars['node']->type, array('NODETYPE'))) {
    $vars['title'] = '';
  }
}

You can easily replace THEMENAME with the name of your theme and NODETYPE with the type of node you want to hide the title for. You can add multiple node types to the array if you need to hide the title for more than one type of node. If you want to globally hide the page titles you can use this code.

function THEMENAME_preprocess_page(&$vars) {
  $vars['original_title'] = $vars['title'];
  $vars['title'] = '';
}