Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By stbasil on
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
There's probably a better
There's probably a better way, but I just hit the spacebar and Drupal accepts it.
Awesome!
Thanks.
I think that's a good way to
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:
became:
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.
6.x doesn't appear to accept
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.
Front Page module
Have you tried using the Front Page module?
--
Duplika | Web Hosting
Hmmm -- I'll look into that,
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.
...
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).
Sounds good
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?
just my 2 cents. but can
just my 2 cents. but can you not just setup a custom content type, and a view?
ephman
That's a possibility
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.
easiest
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
Another way
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):
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.
Perfect
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!
Blank titles
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
---------------------------------------------------------------------------------------
this method didnt work for
doublepost deleted
Modify your page.tpl.php file
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?
Easier with CSS
This can be done very easily with CSS. Just add this to your theme's style.css:
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
Thanks mcfilms for your
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;}
Add to theme's styles.css
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
I'm guna have to agree with
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!
I don't know what to say
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
I'm sorry to say that it
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?
" rel="nofollow">
Update! While it wouldn't
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???
css
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
use views?
Just create a view of it and "hide from display" the titles?
i am really new to drupal,
i am really new to drupal, describe create a view..
views
http://drupal.org/project/views
views
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:)
I love views, but....
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
It was .art-postheader
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;
}
Thanks for the tip!
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:
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:
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!
Another way with Content Types.
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:
The file node-page.tpl.php should have title tags to display the title for pages:
4. Edit node-page_notitle.tpl.php and remove:
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
Use javascript/jQuery
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.
Broke when upgraded from 7.24 to 7.25
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?
Sorry, found a fix. I just
Sorry, found a fix. I just replaced
print $node_url">
with
print """>
Save Node without title
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 )
Hope this may help.
Simple way to hide page title
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).
Then in the CSS file add a line like: