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!













Re: How to hide a node title?
Thanks! Like the tip!
Re: How to hide a node title?
It's not working in Drupal 5... Any other ideas?
Re: How to hide a node title?
Sorry for the slow reply; I've been a-travelin'.
Let me try the hidden-node-title technique here again. Steps in my test:
1. I created a new page with title "Testing Hidden Node Title" (without quotes).
2. Per instructions, I opened the theme's page.tpl.php file, found the line
and changed that to
3. I saved the theme's page.tpl.php file and refreshed the test page.
Hmm, seems to work fine here. The test page is at http://www.drupalace.com/page_testing_hidden_node_title ; it now appears without title, at least for me. (Note: the title still appears in the browser's window bar at top, which is fine by me.)
If it won't work for you, I can only suggest the problem is perhaps:
a. Syntax error in your page.tpl.php file modification; or
b. You're modifying page.tpl.php file in the wrong theme (please don't laugh; I've done that sort of goof so many times); or
c. For some reason, this technique doesn't work with whatever theme you're using. (Any theme I'd know? FYI, I'm using my own Zen-derived theme.)
Can you test again and confirm that it doesn't work?
Re: Trick Bin: Hiding a Node Title
I like this solution for the "quick fix"...
However, it seems like there should be a much easier (Modular) solution to this. This is an option that I use VERY regularly when putting sites together... there may be tons of splash pages for sections of a site that are heavy on graphics, and nothing like the content of the rest of the site.
I'm new to drupal myself, but couldn't it be solved using page-front.tpl.php for your homepage, and removing the title from that one?
I'm still trying to figure the best way to display custom content using views, cck, the nodeteaser on your recommendation, and my custom regions that I have in my homepage layout.
seriously though, this should be a default option...a lil checkbox for "display title" checked by default... or a pretty simple module could do the trick. " I say that, but my first custom module has yet to be finished... so easy sounds easy, but maybe not quite...
Re: Trick Bin: Hiding a Node Title
Hello! I believe you are completely right: a separate tpl.php page for the homepage is one way to go about it, and is a good solution for many custom page needs. I myself haven't implemented that, but I've seen the method suggested in answer to many drupal.org forum questions. All it takes is a little willingness to learn to parse PHP; for tpl.php files, I find that isn't too hard. (But I haven't tried any really fancy tricks yet, either.)
I also agree thoroughly about having show/hide title (or other fields) as a per-node checkbox option; that would be wonderful! To have titles, teasers, author info, etc. all implemented consistently with a simple option for show/hide, as a part of Drupal core, would add great flexibility to page display.
Post new comment