1

We are creating an API using Views/Views Datasource and we want to output the Body field with markup already in the field not plain text. How can we do this? This Views_PHP approach just outputs the standard Body field as text.

$nid = $row->nid;
$node = node_load($nid);
$display = array('type' => 'ugc');
$output = field_view_field('node', $node, 'body', $display);
print render($output);

On the example below the @papermill should be a link if this was rendered on the front end.

Body Field output

1

No need for Views PHP, in the settings for my JSON putout it ticks Plaintext output by default! I had Plaintext Output ticked

UPDATE: this does answer the question but we can no longer render our REACTJS App on the front end because i presume of some kind of encoding issue with some characters inside the Body field?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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