hiding the node title on my front page
sks24 - May 26, 2009 - 02:16
Theme: Garland
I apologize if this is obvious, but I can't determine how to hide the node title on my front page.
Just so we're clear, I'm referring to the title field on front pages that is both mandatory and automatically contains hypertext.
I tried pasting the following code as directed, but it kept breaking my theme:
<?php
function THEMENAME_preprocess_page(&$vars) {
// Titles are ignored on the front page.
$vars['original_title'] = $vars['title'];
if ($vars['is_front']) {
$vars['title'] = '';
}
}
?>I would be content with disabling the hypertext link.
Thanks in advance,
Scott

Could you give more
Could you give more background? Where are you pasting the code? What do you mean 'breaks' your theme?
hiding node title
Thank you very much for your replies.
Sorry about the insufficient information. I'll get better at this. To answer your questions:
I pasted the code right at the top of the template php file. "Breaks my theme": It threw a syntax error at me and wouldn't load the page.
Seems like there would be a dedicated module for this issue? I see that quite a few users ask after it.
Thanks again,
Scott
=-=
did you change THEMENAME to your themes actual name in the preprocess ?
thus garland_preprocess_page should be the name of the function
node title
Thanks VM:
did you change THEMENAME ["Garland"] to your themes actual name in the preprocess?: Yeppers.
thus garland_preprocess_page should be the name of the function: It was so.
Again, thank you:
SKS
And did you get rid of the
And did you get rid of the
<?phpand?>, and made sure the code was pasted after the<?phpthat already existed in the file?You did not post the syntax error. Seriously, if you want help you need to do a better job providing information.
Sorry! I was thinking the
Sorry! I was thinking the same thing regarding the syntax error after I sent those last replies . . . dumb, especially after pledging to do better.
After finding this, my problem is solved:
Check the file "node.tpl.php" in the theme directory of the theme you're running. In the Zen template for instance, the code that you should be looking at, is:
<?php if (!$page): ?><h2 class="title">
<a href="<?php print $node_url; ?>" title="<?php print $title ?>"><?php print $title; ?></a>
</h2>
<?php endif; ?>
Replace it with:
<?php if (!$page): ?><h2 class="title"><?php print $title; ?></h2>
<?php endif; ?>
This will remove the hyperlink on all content appearing on the front page.
Thank you both very much.
I really do try to figure these things out on my own, and had spent two days, on and off, trying to get around this one before asking for help.
Best,
SKS
no "Marked Solved"?
I guess there's no place to mark these "solved," no?
=-=
not without editing the node, which I don't suggest.
In future wrap your code snippets with code tags so that they can be easily read. I've edited your comment to add these tags.
Thanks VM:
Will do w/r/t/ code snippets + code tags. Again, thank you for your time and advice.
SKS
How to hide a node title in Drupal
I've got an online post on hiding node titles in Drupal, to which helpful readers added many more techniques and tips. The discussion might not perfectly target your question, but I think searchers for general methods of hiding node titles are likely to stumble across your post, so I'll add the URL here for their reference:
http://www.drupalace.com/blog_entry_trick_bin_hiding_node_title_2007_07_03
As for leaving the node title intact but hiding just the hyperlink, I myself haven't tackled that yet...
--------
Manuals, Q&A and more for the Drupal beginner
Thanks Drupal Ace:
Checked out your blog, and I'm sure I'll be back for visits.
Thanks for making this issue # more useful.
Best,
Scott