Hi there,

I'm having a "scratch my head" day with this one. I'm trying to hide the node's title for certain pages.
In Drupal 6 I was using the Barlow theme and I copied the node.tpl.php file to node-notitle.tpl.php.
"notitle" is the machine readable name for content type nodes without titles. In this file I simply commented out the " print $title; " and saved and it worked great.

Now I installed Drupal 7, using the Bartik theme. When I comment out " print $title; " in node.tlp.php, it removes the title from the front page, however it still shows in the actual node. - so that didn't work.

When I comment out " print $title; " in page.tpl.php it removes the comment for all the nodes, which means this must be the right place to comment out that line. So my content type machine readable name is "notitle", and I thought by making a copy page.tpl.php to page-notitle.tpl.php, and commenting out " print $title; " that it would work, but it simply just doesn't work.

Is there anyone that could please give me advise on this? I've spent many hours just trying to find a solution to this for Drupal 7 and came up with nothing. It might be that I'm misreading something, or not understaning it - I don't know, but could anyone please help me????

Thanks in advance,

mseraphim

Comments

mseraphim’s picture

Component: page.module » Bartik theme
Priority: Major » Critical

This has also been posted in the following article:
http://drupal.org/node/1057982

Simply put, I need certain pages on my website without node titles. There were a few suggestions that I tried to follow and it worked, except for one thing.

This is what I did:
1. I created a new content type and called it “notitle”. The machine readable name for it is also called “notitle”.
2. I then created a new node in this content type just to test it.
3. I opened the page.tpl.php file and did the following I changed the lines from:

      <?php if ($title): ?>
        <h1 class="title" id="page-title">
          <?php print $title; ?>
        </h1>
      <?php endif; ?>

To this:

<?php /*?>This below checks for 'notitle' content type and then it doesn't print the title,
          however it still prints the normal title for page content type<?php */?>
      <?php if ($title && $node->type != 'notitle'): ?>
        <h1 class="title" id="page-title">
          <?php print $title; ?>			  
        </h1>
      <?php endif; ?>

All of this worked great and it then didn’t display the title anymore for the “notitle” content type’s nodes, however…

4. When I log in as administrator I get the following error message:

* Notice: Undefined variable: node in include() (line 191 of C:\wamp\www\themes\bartik\templates\page.tpl.php).
* Notice: Trying to get property of non-object in include() (line 191 of C:\wamp\www\themes\bartik\templates\page.tpl.php).

The code for line 191 is the following:

      <?php if ($title && $node->type != 'notitle'): ?>

5. Do you have any suggestions please? I’m not very good with php, but certainly try my best. Any help would be great.

Thanks in advance.

Mseraphim

morbus iff’s picture

Priority: Critical » Normal
Status: Active » Fixed

Not critical as it does not break all Drupal sites. The notices are ignorable, but if you'd like 'em gone, try replacing them
with the following (they're caused because page.tpl.php is used for *every Drupal page*, not just those that are nodes):

<?php if ($title && isset($node) && $node->type != 'notitle'): ?>

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

lelizondo’s picture

Probably old but Node Form Settings allows you to hide the node title by content type.