By bfaler on
Hey everyone,
I am working on a site where I am trying to add a subheadline directly underneath the title of an article page. I've gotten as far as creating the field and adding it to the interface, but I cannot figure out how to access the content of that field from my page.tpl.php file.
I found this article, but it seems to be a bit outdated:
https://drupal.org/node/316688
Can anyone clue me in to how I go about doing this with a Drupal 7.x installation? Am I just missing something incredibly obvious here?
Comments
page.tpl.php is the template
page.tpl.php is the template for your overall site (theme). It is rendered on every page, whether the page is a node or not. Since you are speaking of articles, you are likely speaking of nodes (since the standard installation profile comes with a pre-defined content type named 'article'). As such, you probably want to work with node.tpl.php not page.tpl.php.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks for clarifying that.
Thanks for clarifying that. I was originally working with that file, but no changes I made there seemed to have any effect on the site at all. I'll go back and experiment with it some more, but assuming node.tpl.php is the correct file, how can I access my field in that file?
I figured out how to access
I figured out how to access it in node.tpl.php:
print render($content['field_subtitle'][0]);However, that really does not do what I want. If I open up the article itself the subheading (subtitle) displays more or less the way I want it, but on the front page the field is empty when printed.
This is what I am looking for:
(Front Page)
Article 1
Subtitle 1
Content
Article 2
Subtitle 2
Content
Then on the individual article pages:
Article
Subtitle
Content