When I create 'page' content I am forced to make a title for this content (which makes sense so that I can identify it); however, can I hide the title at the top of the page when i'm viewing the actual content?

Comments

scoutbaker’s picture

That's part of your theme. You can read about theming in the Drupal 6 theme guide.

wr5aw’s picture

You can selectively (for each node) hide the title using a CCK checkbox field. Here's how I did it:

  1. If you haven't installed it already, install the CCK module. You can get it at http://drupal.org/project/cck
  2. Create a CCK checkbox field and name it hide_title
    1. Go to admin/content/types
    2. Click on manage fields for the content type you want to edit
    3. Under Add/New Field, enter a label (this will be displayed on the node edit page)
    4. Enter hide_title as the field name
    5. Select Integer as the field type
    6. Select the Single on/off checkbox widget
    7. Click Save (you'll get a page with settings for the field)
    8. On the field settings page, enter some help text if you'd like
    9. Under Default value, check the box if you want all titles hidden by default
    10. Under Global Settings, Check Required
    11. Set the number of values to 1
    12. Enter the following under Allowed Values List
      No|0
      Yes|1
    13. Click Save Field Settings
  3. In your theme's template.php:
     function yourthemename_preprocess(&$vars, $hook) {
      $field_hide_title = 0;
      if ( isset($vars['node']->field_hide_title[0]['value']) ) {
        $field_hide_title = $vars['node']->field_hide_title[0]['value'];
      }
      $field_hide_title = $field_hide_title == 1 ? TRUE : FALSE;
      if ($field_hide_title && arg(0) !== 'search') {
        $vars['title'] = '';
      }
    }

Now, all you have to do is check/uncheck the Hide Title field when you edit the node. The only drawback to this method is you'll have to edit any existing content to hide their titles.

WARNING - the code you enter in template.php could break your site if there's a typo in it. Be sure and test it first before adding it to your production server.

ckeen’s picture

Thanks a lot this is key!