I am trying to get the title to display only on pages in one content type. I have the typical "Page" and "Story" content types and have added a custom content type called "News" with the system name "news". I want the title to display only on nodes with the "News" content type. Since this is a relatively static site, I created my own page.tpl.php using the variables here: http://api.drupal.org/api/drupal/modules--system--page.tpl.php/6. If you need a copy of my page.tpl.php, please let me know and I'll send it to you. I did not use one of the themes that come with Drupal, I made my own. Oh.. I have the Path module set up so that any News content types go under news/[title-raw].

Basically, my problem is this: On the main pages of the website I have it set so that the right sidebar has a teaser of the most recent News post and a link that says "Read More" (made within Views - this is a block). The "Read More" link goes to a page with the full article. The full article is displayed as follows (again, set up as a Page in views):

<h2>Title</h2>
Date Posted (displayed as M. j, Y)
Body

Then in the right sidebar of this page (and all news pages), I have links to the older News posts. The links go to the actual node. Within this node, I want to display the title and the date posted, but it is only displaying the body of the News post.

I used to have the News section set up as a blog using the default Blog module in Drupal but I got so frustrated with the things I couldn't control within it that I recreated everything in the "News" content type. Unfortunately, I still can't figure this out. I'm sure it's something I'm missing, but I just don't know what.

I have the following modules installed and enabled (some of these probably aren't affecting this, but I'm posting anyway in case they might be the cause of the problem): Views, Custom Search Box, Imagemenu, Pathauto, Token, Advanced Help.

Things I've tried: Creating a node-news.tpl.php with this <?php print $title; ?> above the content area (which is where I want the node title displayed).
I also tried just creating a node.tpl.php with the above code and with this:

 <?php if ($page): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?> 

Nothing seems to work. I've searched the forums for almost three whole days now trying to figure this out and I just don't know what I'm doing wrong or what I'm missing. Any help would be greatly appreciated! If you need more info or need a copy of my code, please let me know. Oh - I haven't even attempted to get the "Posted Date" to work yet, so if you could enlighten me on how to do this within any "News" content types, that would be fantastic!

Comments

vm’s picture

after altering the tpl.php file are you clearing your cache tables / theme registry per documentation?

crosputni’s picture

Yes. I even tried accessing it from someone else's computer to see if maybe my ISP was caching the page and that's not it.

crosputni’s picture

can anyone give me an idea of what to put in the node.tpl.php file? Maybe I'm missing something that you guys are assuming I have??

Also, will creating node-news.tpl.php and adding some kind of code like this (below) work??

<?php print $title; ?>

Maybe what will work best is if you assume I didn't tell you anything above and just tell me what'll work to get the title to show up on a specific content type? Any help is so very appreciated!

vm’s picture

that should be it. are titles working in a core theme? maybe the problem isn't at the theme layer if they aren't working in a core theme.

crosputni’s picture

Still not working. I don't know what I'm doing wrong. :(

Would the fact that I am using paths (URL Aliases) cause this at all?? I have the URL Aliases setup so that any "News" node type creates as news/[title-raw]. The machine readable name is "news". I would assume it wouldn't matter, but is it possible that the node-news.tpl.php isn't being recognized because of the URL alias settings?

Regarding what you asked above - I don't have titles in the page.tpl.php file. I don't have the $title attribute in page.tpl.php at all. I thought that the node-news.tpl.php wouldn't need that if I code it in to node.tpl.php or node-news.tpl.php. If the problem isn't in the theme layer, do you have any idea what else could be causing this?

BTW - thanks for your help VeryMisunderstood. I really appreciate it!

crosputni’s picture

I'm using completely custom page.tpl.php and node-news.tpl.php files. No base theme. Do I need a node.tpl.php file even though the rest of the content types are the same as the page.tpl.php? Right now all I have with "node" in the filename is node-news.tpl.php. Maybe that's the problem!? Let me try that. I'll let you know if it works... Keep your fingers crossed! :)

vm’s picture

yes. your theme needs node.tpl.php and node-contenttype.tpl.php

crosputni’s picture

Thanks. I figured out the problem - it was in my node-news.tpl.php file - I forgot a ; ... gotta love how much trouble those things can cause if you misplace them! :) You'd think I would've noticed it sooner with how much I was staring at that file.