2

There might be a simple answer to this but it's driving me crazy. I'm working on a template for an article node and I want the byline to display this way:

By Author Name

I don't want to change the field label in the web form, so I just want the "By" to be inserted through the node template. No matter what CSS styling I use, the byline field always displays like this:

By
Author Name

Is there a way to get the label and field to show up inline?

Here's the PHP I'm using in the template:

<div class="newsbyline">
  <?php print t('By'); ?> <?php print render($content['field_newsbyline']); ?>
</div>

Setting the "newsbyline" <div> to inline doesn't seem to be working.

1
  • 1
    In CSS, try setting the tags surrounding "by" and "Author Name" to float:left; and then check. Apr 24, 2012 at 23:13

1 Answer 1

0

It would be helpful to see the markup that surrounds the newsbyline field. I'm guessing there's a div or some other element around field_newsbyline that's a block element by default. If you change the CSS for that element to display: inline that may solve the problem.

Alternatively, if the above code is in your node template, you could adjust the markup in the field template instead:

  1. Copying field.tpl.php from the base theme you're using or from Drupal core's /modules/field/theme/ into your theme
  2. Rename it field--field-newsbyline.tpl.php (assuming field_newsbyline is the machine name of your field)
  3. Edit that template to add <?php print t('By'); ?> in the appropriate spot.

By making the change in the field template, you should be able to get your code inside the wrapper div, rather than having it outside.

Not the answer you're looking for? Browse other questions tagged or ask your own question.