Creating a Node without a title or a default title

punteney - August 3, 2003 - 20:55

Is there a way to create a node without a title, or to use a default title the user doesn't enter? I'm working on a quotations module and the quotation doesn't have a title just the actual quotation and the author. Is there a way to not have the title text box show on the submit quote screen? Maybe use a hidden text field that has a set value like "quotation" in it?

Or is there a better way to do this then trying to make the quotes into a node?

Thanks,
--James

not currently possible

moshe weitzman - August 4, 2003 - 00:35

node.module adds the title field and module authors may not currently override that. please submit a feature request.

No title at nodes...

Anonymous - August 4, 2003 - 00:55

If i'm correct, this feature is submitted several times on the devel-list.. (Please correct me if i'm wrong)
I thought Al made a patch for this, but also not sure about this...

No Title Solution

LinusKapatrick - May 17, 2005 - 06:08

I can understand a need for title. 1) SQL key and sorting and 2) menu navigation. But there are times when pages need to be without title for better looks. The solution could be simple (but need to be implemented):

1. In the future release, add a title field in addition to the key field. The title defaults to the key automatically; or...

2. To kill 2 birds with 1 stone, title can be formatted with font size, style and color. In this case, you simple set to smaller size and use the background color to make it completely invisible.

Custom node with flexinode & special PHPTemplate

Samat - May 17, 2005 - 06:53

Just an interim solution that does not require any writing of code (and may be forward compatible).

Create a custom node type with something like flexinode, named MyNode. Put whatever fields you need (including title).

Using PHPTemplate, make a copy of node.tpl.php to node-MyNode.tpl.php. You can remove display of the title in HTML in this custom template, but the browser will maintain the node title in it's title bar.

Samat

I just tried this

whenigodeaf - May 17, 2005 - 18:23

And it didn't work. I must be missing something. Can you give a little more detail on how to create a custom node using flexinode?

spoke too soon...

Samat - May 18, 2005 - 03:28

Eh, I think I spoke too soon. What I described with flexinode does not work. Drupal renders the heading outside of the node.tpl.php when it's a node view display.

Thus, you can make the heading dissappear in a teaser display (which isn't really useful), since that heading is rendered within node.tpl.php. But, for node view pages, the heading remains.

So... the obvious solution... which then is absolutely NOT clean, mess with the main page.tpl.php to specifically not print out a heading for that page if the title matches a page.

I have an example up at:

http://www.hotnudiegirls.com/~xjjk/blogs/drupal-4.6.0/node/25-a_node_pag...

(pardon the mess, it's a test installation for when I migrate my main site over to drupal. it will be deleted soon)

If there only a few page titles, you could probably define an array in the PHPTemplate file page.tpl.php and make sure the node being displayed is none of those pages. If you don't know PHP that well I can devise the code for you, but like I said earlier, this isn't very kosher and is a hack. Sorry for the mistake and being misleading!

How to do this with PHPTemplate and CSS

Samat - May 18, 2005 - 05:23

I just thought about the correct way to do this with PHPTemplate and CSS. It still would only work efficiently with a small number of pages you wish to do it for.

The idea is inspired from things like the URIid extension for Mozilla Firefox. Basically, we add a new class to our body tag so that we can hide what we want using CSS.

In the PHPTemplate theme, in page.tpl.php, I changed my body tag to look something like:

<body <?php
 
print theme("onload_attribute");
  if (isset(
$node)) {
    echo
" id=\"node-" . $node->nid . "\"";
  }
 
?>
>

This will create a ID tag that you can then, in your CSS style sheet, use to select for the page. Say the id of the node whose title you want to hide is 42. In your CSS stylesheet:

div#node-42 h1 {
  display: none;
}

I don't know why I didn't think of this sooner. This method is very simple and requires minimal modification of PHP code.

Edit: Since the these node classes are unique, they should be IDs. Changed above code examples to reflect this.

this doesn't seem to work for me

jenpasch - July 22, 2005 - 18:55

I changed my theme style sheet (using box_grey) to adjust h2 content-title (which is the style for this bit). But it doesn't work. Ideas? My node is correct.

A solution that worked for me (!)

donnoit - August 21, 2005 - 00:03

I had a need to remove the title from a page that I was using as my homepage.

The solution tamasrepus suggested would have worked if node were passed down to page.tpl.php but in phptemplate it isn't (at least not in drupal 4.6). But his idea was on the right track. You can use the title of the page instead.

Follow this 3 step process.
Step 1. For every page which you actually don't want to show in the main content area, give your page a distinctive title without any spaces in the title. Choose something that is unique enough but doesn't look bad ('cos it'll still show in your browser's window-title). In my case I gave this page a title = 'HOME'.

Step 2. Then you edit the page.tpl.php in your theme directory to put the following:

<body <?php print theme("onload_attribute");
    echo
" id=\"title-" . $title . "\"";
?>
>

in place of this

<body <?php print theme("onload_attribute"); ?>>

For me, this placed id="title-HOME" as the attribute of my body element.

Step 3. Put the following at the bottom of your style.css :

body#title-HOME h2[class="page-title"] {
display: none;
}

What this is saying is : do not display any h2 element whose class attribute equals "page-title", if the h2 is under a body element has an id attribute equal to 'title-HOME'. The "page-title" class is set by drupal.

(In my case the title was being displayed as an h2 heading. Make sure it is same for you by looking at your browser's source. Else, you'll need to replace h2 above with whatever the element is.)

In your case 'HOME' should be replaced by whatever distictive title you give. The only caveat is to not leave spaces in the title (use underscore instead if you have want to use more than one word).

You'll need to put a similar block in your CSS for every title that you want to hide.

Have fun!

better solution (found looking for a workaround for IE)

donnoit - August 29, 2005 - 04:10

The solution above works with firefox but not with Internet Explorer. Microsoft doesn't seem to conform to the CSS standard.

I discovered a simpler solution. 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.

No need to do the steps I indicated above !

Why not a comment sequence?

avskip - June 26, 2005 - 16:14

In the online handbook, it says you can use an html comment < !--This would be unseen --> as a title. I tried it, and it doesn't work. It's converted to &lt and &gt codes in the page. I tried it as raw input and that didn't work either. Apparently the title portion is handled differently than the body.

Wouldn't it be simpler to allow it to index these comments and display them as a comment - ie: not there.

Just a thought.

Titles and Filters

com2 - July 21, 2005 - 12:35

+1

I agree. The same should be done with the block titles. In 4.5.x you could put a comment or even any HTML in the title. In 4.6.x this got disabled.

What if you want graphical title, a PNG or even a SWF? In 4.5.x it was still possible. These unasked changes make it impossible for me to upgrade to 4.6.x because I have made a couple of sites based on this removed feature.

It would even be better to let node titles be handled by filters. If HTML is not filtered from the text body then it should not be filtered from the title either! The same can be done with block titles.

That way the developer is not imposing his choice be it is left to the user to decide.

+1

zirafa - August 9, 2005 - 23:08

+1
I think perhaps submitting an actual feature request would get people noticing.

PHPTemplate solution

com2 - August 31, 2005 - 09:37

See http://drupal.org/node/28537 and my comments for another solution using PHPtemplate.

I'm still wondering how to replace the title with an image or Flash animation (for special fonts etc.).

Enable customizing of "Title" field on node forms

kamnabi - October 5, 2005 - 08:50

I found an interesting patch.

Enable customizing of "Title" field on node forms
http://drupal.org/node/10056

now *is* possible

moshe weitzman - November 16, 2005 - 14:20

HEAD has this feature today. will be in 4.7. see http://drupal.org/node/22218

This worked for me

lbjerryh - August 29, 2006 - 02:46

I just stuck this:

h2 {
margin-bottom: 0px;
font-size: medium;
margin-top: 0px;
}
.page-title {
padding: 0px;
margin-top: 10px;
margin-bottom: 10px;
text-align: center;
display: none;
}

at the top of my content that I put in the node you created. Make sure you have the correct format selected to validate the code.

how?

captaintim - February 15, 2007 - 22:58

I want to be able to not display the page title on a couple of pages, so was looking at this answer. Exactly what tags and things do you need to get this code to work and do the tags need to be on seperate lines or anything? I'm very new to php, so sorry if this is a stupid question.

Take a closer look at:

creazion_dev - January 14, 2007 - 12:14

Take a closer look at: Automatic Nodetitles.

---------------------------------------------
last projects: www.happyfaces-kinderschminken.de - www.3p-consulting.com

I tried that

brianpeat - February 7, 2007 - 00:33

All it does is hide the title FIELD, and then let you auto generate a title. It doesn't let you hide the actual title.

I personally just want a little check box for every piece of content, just under the title field that says "display title." Unchecking it would just not display the title.

I did this by

keylope - February 22, 2007 - 19:43

I created a custom field called hide_title through CCK.

Then in the page template, I check for this variable, if it is set, then don't write out the title line.

Sorry that I can't be more specific, but that's the gist of it.

Hope that helps.

I need to know how to do

kevincompton - March 20, 2007 - 21:14

I need to know how to do this, can somebody post the details??

CSS in the game...

Ldectus_gr - March 25, 2007 - 18:29

Since I had a content-type that I didn't want to show the title of it, I copied the node.tpl.php to a new file called node-page.tpl.php (this is the content type I needed to remove the titles from).
After trying to figure this out, I tried something else. I added to the end of the node-page.tpl.php the following html-css:

<STYLE type="text/css">
   H1 {display:none}
</STYLE>

.. and it worked! Remarkable !

Note: My title is using the h1 heading, change yours as needed.

I hope this helps ... !

removing all titles in nodes with CSS is easy

BassPlaya - August 19, 2007 - 05:18

I'm working with 4.7.x. and the burnt theme.
A very easy way to remove all those titles is to change the h1 that is responsible for the title in the page.tpl.php of the theme
<h4 class="title"><?php print $title ?></h4>
into h4 or h5 or some tag that you probably won't use in the future. Then you change/add a style to your style.css in the theme's folder like this
(basically the same method as mentioned by Ldectus_gr and others):


h4 {
dispaly: none;
}

and that's it. It doesn't show up anymore.
Now, I don't really understand why I couldn't just change the title class in there, I've tried to find where it is styled and I didn't find it in the drupal.css and neither in the style.css, strange...

Hiding the Node Title by Node Type

chicablanca - April 24, 2007 - 21:28

Here's a page about hiding the node title for a specific type of node in drupal 5.x http://drupal.org/node/138910

palantir.net | moonsdawn.com

 
 

Drupal is a registered trademark of Dries Buytaert.