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

mtsanford - May 26, 2009 - 03:22

Could you give more background? Where are you pasting the code? What do you mean 'breaks' your theme?

hiding node title

sks24 - May 26, 2009 - 16:21

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

=-=

VM - May 26, 2009 - 03:24

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

sks24 - May 26, 2009 - 16:27

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

mtsanford - May 26, 2009 - 16:45

And did you get rid of the <?php and ?>, and made sure the code was pasted after the <?php that 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

sks24 - May 26, 2009 - 17:37

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"?

sks24 - May 26, 2009 - 18:04

I guess there's no place to mark these "solved," no?

=-=

VM - May 27, 2009 - 00:11

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:

sks24 - May 28, 2009 - 00:04

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

Drupalace - May 27, 2009 - 07:32

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:

sks24 - May 28, 2009 - 00:15

Checked out your blog, and I'm sure I'll be back for visits.

Thanks for making this issue # more useful.

Best,
Scott

 
 

Drupal is a registered trademark of Dries Buytaert.