I am attempting to get two fields to display inline. Specifically, I need the Locator, and the Body fields to display inline.

My Locator simply states the location of a post in plain text.
i.e. "Duluth, MN - "

My Body is the story.
i.e. "Are strange things happening in your house? Lights turning off and on by themselves? Or are you hearing voices in the basement?"

I'm attempting to display them inline but am having the hardest time.
i.e. "Duluth, MN - Are strange things happening in your house? Lights turning off and on by themselves? Or are you hearing voices in the basement?"

They need to be two separate fields for use in a Geo Locator.

I use the Display Suite module, and from my web searches I have found that it is possible to use the custom Code Field option to pull the data by Token, or PHP $entity.

I can get it working just fine with both Token, and PHP $entity, but cannot figure out how to get them to be inline?
i.e My Result is always:
"Duluth, MN -
Are strange things happening in your house? Lights turning off and on by themselves? Or are you hearing voices in the basement?"

I'm sure I'm missing something easy, and/or just overlooking something.

Here is the code I've used:

Works! Tokens!

[node:field-locator] - [node:body]

Works! PHP!

<?php print 
    $entity->field_locator['und'][0]['value']; 
?>

Doesn't Work!? PHP!

<?php print 
    $entity->field_locator['und'][0]['value'];
    " - ";
    $entity->body['und'][0]['value'];
?>

Works! PHP!

<?php print 
    $entity->field_locator['und'][0]['value'];
?>

<?php print 
    " - ";
?>

<?php print 
    $entity->body['und'][0]['value'];
?>

Comments

akalata’s picture

Assigned: Ganginator » Unassigned
Tangogolf’s picture

The problem is you're using one print command and three semi-colons. You can chain strings together by using a period. Try something like this:

    print $entity->field_locator['und'][0]['value'] . " - " . $entity->body['und'][0]['value'];
chrisjlee’s picture

Status: Active » Postponed (maintainer needs more info)
swentel’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Yes, you need to concatenate the strings as explained in #2

Ganginator’s picture

I forgot to list that with the others I've tried.

It also does work, but does not display inline, and furthermore it does not list a summary, or trimmed body.

So, to be specific:

Works, PHP:

<?php 
    print $entity->field_locator['und'][0]['value'] . " - " . $entity->body['und'][0]['value'];
?>

Does not display inline, and furthermore it does not list a summary, or trimmed body.?

i.e My Result is always:

"Duluth, MN -
Are strange things happening in your house? Lights turning off and on by themselves? Or are you hearing voices in the basement?... (FULL TEXT)"