I am running Drupal 6 and I would like to be able to hide the node titles so that they don't display on the page. I only want to do this on certain pages. How can I accomplish this?

Thanks!

Chris

Comments

Griff1324’s picture

anyone?

wimvb’s picture

In the page.tpl.php file of your theme look for the follwing code-snippet:

....................

<?php print $breadcrumb ?>
    <h1 class="title"><?php print $title ?></h1> 
    <div class="tabs"><?php print $tabs ?></div>

.........................
Change the line with class="title" into:

<h1 class="title"><?php if ($node->nid == node_number_of your_page) {print $title;} ?> </h1>

and substitute in the above your actual node-number for: node_number_of your_page.
The title is then only displayed on that page. Of course you could extend the condition of the 'if'-statement to include/exclude other nodes.

Boletus’s picture

Sometimes the "Drupal" way of always making the most rudimentary things hard as hell to accomplish is laughable. :P

gerryk’s picture

If it weren't so 'laughable', it wouldn't scale, updates would be impossible, theme agnosticism would be impossible... etc. etc.

junni’s picture

danyalejandro’s picture

yay! it scaled!

mcfilms’s picture

auto_nodetitle hides the title from the data entry form. It creates a title for you. But it does not prevent the title from displaying.

Using the tip above on my Zen theme I did the folowing:

•I copied page.tpl.php out of the Zen folder and into my theme.
• I found the section that looked like this:

       <?php if ($breadcrumb || $title || $tabs || $help || $messages): ?>
          <div id="content-header">
            <?php print $breadcrumb; ?>
            <?php if ($title): ?>
              <h1 class="title"><?php if ($node->nid == node_number_of your_page) {print $title;} ?> </h1> 
            <?php endif; ?>
• I replaced that line that begins with <h1 class="title"> and set it to:
<h1 class="title"><?php if ($node->nid != 8) {print $title;} ?> </h1> 

On my site node 8 was the one I was targeting to NOT have a title. So that line says if we are not on node 8, print the title.

Hope this helps someone.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

HansR’s picture

isn't views created just to handle how nodes are to be handled ?

I'm going to try the auto nodetitle now, and if it does what it sais it should be the perfect solution together with views...

jvieille’s picture

Yes, it helped!

I spent more than one hour solving this trivial issue.
It is absolutely abnormal that Drupal does not propose natively the option to hide the title at the content type and node levels.

Even this trick is unacceptable as you must modify a theme so the change will be dismissed as soon as youy switch to another theme or the theme is updated.
This is a hack, not a solution.

Is there any way top do this change at the Drupal level, as a module (because new feature are forbidden at this stage - though this is almost a bug...) ?

JV

offal’s picture

Ok, I'm a novice and know nothing about coding etc, but I got auto_nodetitle to hide the node title for me after a bit of playing around. Here's how:

I have the Token module installed as suggested in the readme of the auto_nodetitle module.

In "Home » Administer » Content management", click 'edit' for the type of content in which you want to hide the node titles (page in my case) and open the "Automatic title generation" menu.

Enable the "Automatically generate the title if the title field is left empty" option.

In the "Pattern for the title:" field type in the [title] pattern.

Now in your newly created node you leave the title blank.

That was it. Worked for me. Perhaps it's a fluke....

The beauty is that when you do want a title, you just type it in as per normal.

To do this retrospectively on already created nodes, follow the instructions in the readme of the auto_nodetitle module:

Updating nodetitles from existing nodes
---------------------------------------
If you set the nodetitle to be auto generated for some content type, existing nodes
are not affected. You can update existing nodes by going to 'admin/content/node',
then filter for your content type, mark some nodes and choose the "Update option"
"Update automatic nodetitles".

jvieille’s picture

This is the most elegant way to do it by far!
Thank you very much.

JV

knalstaaf’s picture

You can't see what the content is about anymore in your content list (admin/content/node) or blocks (admin/build/block). This may not be a problem in case of a limited use, but if you use multiple nodes or blocks like these, it may become a real pain!

Is there a way this module can resolve this?

P.S.: Updating content with this is not really working for me. The title won't disappear after a save (after being updated as described, clearing the cache and removing the title in the node itself. I'm combining it with nodeasblock, giving it a block title sometimes - same issue. Once it's there, it won't go away.

cossovich’s picture

It's possible for any module to change the variables that get sent to different template files using the hook_preprocess_HOOK function. For the page title we need to be changing the variables that are part of the template_preprocess_page function. So if we want to affect the page title through a custom module we need to create a function called hook_preprocess_page (and replace that first 'hook' with our module name of course!).

Let's pretend we've created a module called persistent_title.module. Here's the code we'd need to add:

/**
 * Implementation of hook_preprocess_HOOK()
 */
function persistent_title_preprocess_page(&$variables) {
  // Make every page title on the site say "Foo"
  $variables['title'] = 'Foo';
}

If we only wanted the title to be changed on certain paths we need to add some code that checks for the condition we want:

/**
 * Implementation of hook_preprocess_HOOK()
 */
function persistent_title_preprocess_page(&$variables) {
  // Remove the page title for certain target paths.
  $targets = array('some/path', '321');
  $path = $_GET['q'];

  // Make the title blank for pages on the matched paths
  if ( in_array($path, $targets) ) {
    $vars['title'] = '';
  }

}
ishmael-sanchez’s picture

If your theme makes use of the $body_classes variable you should be able to target content types and specific nodes. For example with zen, you could have CSS like

.node-type-page h1.title {display:none;}

to remove all titles from page nodes.

jasenmichael’s picture

isn't there an easy way to hide the node title by using an in line css override? so not to have to edit any files.

Peter20ghz’s picture

I have been trying to get rid of the post-headers from my website but no such luck. (http://drupal.org/node/759100)
And also i don't want to have that post-header on any of my pages, old or new ones, they all shall be clean from it.
So i tried the CSS you supplied and changed h1 to h2 and placed it in the end of the themes CSS sheet, but sadly, no joy.

Shouldn't it actually work? it seems to me as it´s kinda the same principle.
Do any of you suggest any other ways to get rid of the annoying post-header?
Any input what so ever is appreciated.

Best regards
Peter

knalstaaf’s picture

When elements with display: none contain actual content that can be considered as relevant by search engines, it could damage your SEO (often used as blackhat technique).

liberiangirl90’s picture

How can I use the method that was mentioned above ( http://drupal.org/node/265773#comment-1631630 ) to hide tabs from a single node, say, number 23?

liberiangirl90’s picture

Anyone?

jvieille’s picture

Please consider this instead
http://drupal.org/node/265773#comment-3055470

I hate modifying themes' or modules' files, and it will be tricky to change the tpl file each time a new node needs hidding its title.
Just use auto node title module as indicated: you can have the title displayed, hidden os created automatically as you want.

JV

liberiangirl90’s picture

Yes, thanks, but I'm asking how to do the same thing to remove tabs, not titles.

mcfilms’s picture

Titles and tabs don't have all that much to do with each other. They come from different places and are displayed differently. You should either start a new thread or (better yet) do a search for: "how do I remove tabs" and read some of the answers. I bet that will lead you to a theming solution or a module (like tab tamer) in no time.

Good Luck!

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

lilon’s picture

JonathanHindi’s picture

Hi,

Hiding tabs in specific node

<div class="tabs"><?php  if ($node->nid !== "23") {print $tabs;} ?></div>

in your page.tpl.php
Change 23 with your node id

Jonathan Hindi

rajesh.sharma1’s picture

.node-type-page h1.title {display:none;}

thanx this is working thanx a lot

pabben’s picture

I don't want to hide all the titles, just some.
This module does what I need :
http://drupal.org/project/exclude_node_title