I'm quite new to Drupal (using 7), but I've managed to set up my content types (e.g. 'concert'
) and I've created a node-concert.tpl.php
whose HTML structure I need to rewrite to fit the information particular to the concert
content type.
I have a wealth of CCK fields (almost all single-line text fields) in this content type, and I know how to access the contents of a field by using <?php print render($content['field_fieldname']); ?>
. My problem is this: Drupal outputs every field on a new line. So, if I have the following fields with the following values:
field_concert_date = January 1, 2013
field_concert_time = 3 PM
field_concert_location = Boston, MA
Drupal will simply output each field value on a new line (all field labels are hidden). The output I want would go something like:
January 1, 2013 at 3PM in Boston, MA
I tried to achieve this by wrapping the output of all three fields in an <h2>
tag, like so:
<h2><?php print render($content['field_concert_date']); ?> at <?php print render($content['field_concert_time']); ?> in <?php print render($content['field_concert_location']); ?></h2>
But Drupal still outputs everything (even the hard-coded text inside the <h2>
tag) on its own line:
January 1, 2013
at
3 PM
in
Boston, MA
I've looked at Customize a field output and Drupal: Print field without markup as well as done some basic Googling, but I can't quite find a reference to this specific problem. I'm assuming the culprit lies in some extra markup that is getting added somewhere that forces a new line at the end of every field, but I'm not entirely sure where it would be coming from. Is it in field.tpl.php
? Or somewhere else? Or is it related to the call to render()
(something that forces a line break after render()
successfully returns the contents of a field)? Like I said, I'm fairly new to Drupal and haven't yet figured out how to pinpoint small-scale (but important!) problems like this.
Thanks!
An additional note: I'm in the process of creating a Drupal theme from scratch, and so far the only CSS I'm pulling in is a CSS Reset.