How can I create a page or story and have it display without the page title? I have a section that's just a list of links with a description, and I don't want the title to show, but it won't let me add it without one.

Comments

_dynamic’s picture

There's probably a better way, but I just hit the spacebar and Drupal accepts it.

.carey’s picture

Thanks.

jessetechie’s picture

I think that's a good way to do it. However, the theme I use (abac) has a background and borders for the h2 tag, so I was still seeing that. I fixed it by modifying one line in node.tpl.php for the theme. This line:

<?php if ($page == 0): ?>

became:

<?php if ($page == 0 && trim($title)): ?>

This causes the title to not even be rendered for any node on your site, if the title is just one or more blank spaces.

retswerb’s picture

6.x doesn't appear to accept a space (or even multiple spaces) as a legitimate title.

I'm just wanting to do this because on my front page I have everything I want there in various blocks distributed throughout the page -- I don't need any post content there. But of course not having a post at all leaves me with the generic Drupal new site message.

I don't want to make any global changes that would prevent my titles elsewhere from showing. I'm sure I can find a way around this, but it would sure be nice to have a checkbox you could mark on a post-by-post basis that would determine whether or not the title was displayed.

Duplika’s picture

Have you tried using the Front Page module?
--
Duplika | Web Hosting

retswerb’s picture

Hmmm -- I'll look into that, definitely looks like a nice option. Thanks for the tip!

I still think though that a far simpler and cleaner solution would be just to be able to choose whether or not to have a given title displayed.

mooffie’s picture

You can decide on some "magic" word that, when appears in the title, the code in node.tpl.php won't show it (use a slight alteration of jessetechie's code).

retswerb’s picture

I really like the sound of that -- but I'm completely php-dumb. Let's say my magic word was 'no_display' (never going to accidentally have that in a real title) -- what would my code line look like?

ephman’s picture

just my 2 cents. but can you not just setup a custom content type, and a view?

ephman

retswerb’s picture

Yes, maybe that would be the easiest way.

The thought I was just playing with was that maybe I could globally un-display the title field, then use CCK to create a new 'optional title' field and set that up to look like a title. That way you could leave the optional field blank and have no title, or fill it in and have a title. This is going to stretch my limited coding skillset though, maybe I'll give up and try to set it up with Views instead.

koppie’s picture

Yeah, Views is definitely the easiest way to go here. Space title and CSS hidden title didn't work for me (Drupal 6.15). I already had a custom view in a block dominating my home page, all I had to do was create a "page" view for the same view with a custom path, and set it as the home page. Couldn't be easier and I got exactly the effect I was looking for.

--Koppie

retswerb’s picture

I found a comment on http://drupal.org/node/221854 that gives a good solution, working fine with my LiteJazz install on Drupal 6.6.

Modify your page.tpl.php file with this (taken completely from nstrassner's comment on the above node):

<?php if(substr($title,0,1) != "_") { ?> 
<h2 class="title">
<a href="<?php print $node_url?>">
<?php print $title?></a></h2> <?php 
    } ?>

Save your change and run cron.

Then anytime you want the title not to display, begin the title name with an underscore (such as _qwerty) and that title will not be displayed.

cbearhoney’s picture

Worked like a charm in page.tpl.php. I just wanted to hide the title for the homepage. Added '' in below line of code.

if ($title != 'unique_homepage_title'): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif;

Thanks!

jonboy18’s picture

Hi
I am trying to find out how to make Drupal 6 accept blank titles for nodes. I found this solution in retswerb's post, but I have no idea where in the page.tpl.php file to put this code. Can anyone help me with this please.
---------------------------------------------------------------------------------------
Modify your page.tpl.php file with this (taken completely from nstrassner's comment on the above node):

if(substr($title,0,1) != "_") {

print $node_url">
print $title

    } 

---------------------------------------------------------------------------------------

BNDAZ’s picture

doublepost deleted

BNDAZ’s picture

 Modify your page.tpl.php file with this (taken completely from nstrassner's comment on the above node):

<?php if(substr($title,0,1) != "_") { ?>
<h2 class="title">
<a href="<?php print $node_url?>">
<?php print $title?></a></h2> <?php
    } ?>

Save your change and run cron.

Then anytime you want the title not to display, begin the title name with an underscore (such as _qwerty) and that title will not be displayed.

this method didnt work for me, i added that code just before the close tag for the body...
all that happened was and underscore was added to the title.
Did i place it in the wrong place?

mcfilms’s picture

This can be done very easily with CSS. Just add this to your theme's style.css:

#node-1 .title {
display:none;
}

Where "1" is the number of the node you are trying to not have a title.

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

jonboy18’s picture

Thanks mcfilms for your input. I have done as suggested but it doesn't seem to have the desired effect. Whereabouts in the styles.css file should I insert the code?

The URL to the story is 'http://localhost....../?q=node/30' so I changed the '#node-1' to '#node-30'.

At the moment it is inserted thus:

/* CSS Document */

* { margin:0; padding:0;}

body{

background:url(images/header_left_bg.jpg) left top repeat-x #FFFFFF;

font-family:Arial, Helvetica, sans-serif;

font-size:11px;

color:#545454;

padding-bottom:19px;

}

#node-30 .title {
display:none;
}

ul, ul li { list-style:none; list-style-image:none; list-style-type:none;}

mcfilms’s picture

Are you by any chance creating a NEW style sheet. You want to edit the currently active style sheet. You just want to add that bit of code to the end. Probably line 600 or higher:
#node-30 .title {
display:none;
}
to the current styles.css

The easiest way to find out which CSS is being used is to download the Firebug plug-in for Firefox and look at the page with it. It will tell you which file and which line of each file controls each element on the page.

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

clarkwolfe’s picture

I'm guna have to agree with jonboy18. I've been looking to get rid of a title and applied the code to my style.css to no effect. I know the site's using it because i can change the colors from there and see the effect immediately. I've thrown the code in many different places and used the correct node number. Oh well.

The php snippet option worked like a charm!

mcfilms’s picture

I don't know what to say. It works for me.

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

jonboy18’s picture

I'm sorry to say that it doesn't work for me. I'm using Drupal 6.14 and theme091. Referring to my earlier post, could someone tell me where, in my node.tpl.php file to insert the php code snippet?

if(substr($title,0,1) != "_") {
print $node_url

" rel="nofollow">

print $title
    }
jonboy18’s picture

Update!

While it wouldn't work in theme091 (which was a purchased theme), I swapped themes to Waffles and inserted the code in the style.css for Waffles and it worked. It must be something about the css for theme091 that prevents it from working???

mcfilms’s picture

Yeah I was starting to suspect your theme was not robust enough to support this. Maybe the CSS selectors for the title are overwritten by that theme. Or maybe they weren't supported by the theme at all. In any case, glad you got it working. (And glad I'm not hallucinating.)

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

StephenRobinson’s picture

Just create a view of it and "hide from display" the titles?

BNDAZ’s picture

i am really new to drupal, describe create a view..

StephenRobinson’s picture

StephenRobinson’s picture

add 2 fields to the view, one which links to its node for the link and the description in the add fields, change the style to list, create a default argument with default show all, add order by and save. You will then create a type page, you only have a default view so far, you then set the url of the page and job done.
S:)

mcfilms’s picture

I love views, but the one thing to keep in mind is that Views output does not display an "Edit" tab to sufficiently privileged users. At least not one that leads to the node content. So you cannot easily edit the original node from the page display.

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

nicholaspapazoglou’s picture

It was .art-postheader instead of .title for me. It depend on the theme you use...

So the finally css for me is:
#node-1 .art-postheader {
display:none;
}

egtalbot’s picture

This helped me a lot. I use one of the zen themes, and the specifics are slightly different, but the concept is the same. Here's what i did:

1.I edited html-elements.css as there is no styles.css. And I used Firebug to figure out that this was the operative css file to use (zen has a whole lot of them).

2.The above code didn't work and it turns out the reason is because the h1 tag with a class of title is not inside the div tag with the ID node-1222 (that's the node number where I am trying to suppress it)

3.Fortunately, there is a node specific class in the page element. It is called, not surprisingly, "page-node-1222".

4.so. . . the code I added to html-elements.css is:

	.page-node-1222 .title 
	{
	display:none;
	}

I actually want to suppress titles for every page of content-type page, but not until I can go through and tweak a few existing pages. After I do that I will replace the above line with:

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

My only concern is that since title is a class not an ID, there may be other uses of title out there that I do not want to suppress. In which case, I believe I could just change the above code to put h1 in front of the .title.

Again, thanks for posting this!

gjb2048’s picture

Hi,

I've created another way of solving this but with using content types for drupal v6. After reading http://www.drupalace.com/blog_entry_trick_bin_hiding_node_title_2007_07_03 which did not quite work, because the title was in the page.tpl.php file.

So, perform the following steps after performing a full backup.

1. Create a new content type say with the type (machine readable one) of 'page_notitle' on your site under Administration -> content management -> content types.
2. In your theme, copy 'node.tpl.php' to both 'node-page.tpl.php' and 'node-page_notitle.tpl.php'.
3. Edit page.tpl.php and remove the offending:

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

The file node-page.tpl.php should have title tags to display the title for pages:

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

4. Edit node-page_notitle.tpl.php and remove:

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

  <?php if ($submitted): ?>
  <div class="meta">
    <span class="submitted"><?php print $submitted ?></span>
  </div>
  <?php endif; ?>

I could not find any way of removing the 'submitted' field from my new content type even though on 'page' types it does not display.

5. Create new content of 'page_notitle' types as desired.

6. If you are feeling brave, existing pages can be converted by editing the 'node' table and 'type' field of the database from 'page' to 'page_notitle'.

NOTE: I've only done this twice on a test and my own website, so I suggest you test the procedure first on a test installation.

Cheers,

Gareth

tyfoo’s picture

Depending on how many pages you are wanting to exclude the title from, you could add a bit of javascript to your page. Something like
$('#element-id').remove();
if you want it gone altogether, or
$('#element-id').hide();
if you don't mind it still being there should someone decide to view your source.

Phix500’s picture

Wow I didn't realize how old this post is. I implemented the method of
not displaying the title if it has an underscore in front.
Worked great, until I upgraded.
Error says "node_url" is undefined in page.tpl.php
Any ideas?

Phix500’s picture

Sorry, found a fix. I just replaced

print $node_url">
with
print """>

ashishdalvi’s picture

1st Method )
Auto Node title module.
This module helps us to save the node with no title.
https://drupal.org/project/auto_nodetitle

2nd Method )

function MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == "YOUR_CONTENT_TYPE_FORM_ID") {
    $form['title']['required'] = FALSE; // This will allow to add the node without title.
  }
}

Hope this may help.

nargonne’s picture

This method is useful when you want to keep the html markup intact and hide the title by using CSS.
Also is good because any user can manage hiding a title with a simple underscore added. For example, "_My Page". Also good because can use URL Alias Settings to remove underscores from URLs so they still look clean (example.com/my-page).

<div id="page-title">
          <?php
          /* Simple method to hide the page title using CSS and without requiring user
           * access to the css file. They only need prepend the page title with an underscore.
           * This way the URL still looks nice, is user editable and employes css to preserve
           * info in the markup here.
           */
          if( substr($title,0,1) == "_" ){
            $title_class = 'title hide';
          }
          else {
            $title_class = 'title';
          }
          ?>
          <h1 class="<?php print $title_class; ?>"><?php print $title; ?></h1>
        </div>

Then in the CSS file add a line like:

.title.hide { display:none; }