How to hide a node title?

So a client wants a site with a custom front page. After struggling with Panels and a number of options, I decided the easiest way to go about this particular request was a regular node, with blocks turned off.

One problem: the node's title was also appearing at top, messing up the graphic look needed. I wanted no title to appear, but Drupal doesn't allow a node without a title, and there's no built-in way to have a node appear with its title invisible.

Question answer

Searching the drupal.org forums turns up a lot of possible solutions, most complex. But among the many solutions on this page http://drupal.org/node/2420, one by donnoit looked simple enough even for me:

Edit page.tpl.php in your theme dir and change the line that checks title != "" to title != "x". Then simply give x as the title to your page and it shouldn't show up.

Okay. I opened page.tpl.php for the theme in question, found this line

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

and changed it to this:

<?php if ($title!="welcome"): ?><h1 class="title">
<?php print $title; ?></h1><?php endif; ?>

where "welcome" (without quotes) is the title of my front-page node.

It works! The node content appears, but Drupal doesn't print out its title. Thanks, donnoit!

Average: 4.4 (8 votes)

Trackback URL for this post:

http://www.drupalace.com/trackback/23

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><br><p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Sorry for the "captcha" spam-detector challenge; the spammers have been out in force. : (
vocabula_y: