1

I'm using Display Suite to show a referenced node inside another node in the default display. But when I edit this node that has the entity reference field on it, it shows me the reference field and I'd like that to show the rendered content of a field of the referenced node. Is there a way in Display Suite or do I have to write some code in a tpl file somewhere?

0

You can create using Views a view with "Entity Reference" where you can make the rendered content you wish to add to the node. Than add a new field of type "Entity Reference" to the node edit form of this node type and set up in section "Entity selection":

  • Mode -> 'Views: Filter by an entity reference view"
  • View used to select the entities -> choose the view machine name you have created for this purpose

Additionally, you can provide a comma separated list of arguments to pass to the view.

To avoid some status messages like 'Do something on load', you should uncheck "Test behavior" in "Additional behaviors" section.

Hope it helps

  • I understand that I can use Views to show a rendered field but this does not answer my question. The default node form of a content type shows the fields of that content type and that's what I need but there is 1 field which is a reference field and that field has to show a particular rendered field of that referenced node ON the node form of the content type that is being edited. As extra information, the reference field does not need to be edited but is only used to show content ON THE NODE FORM. – BassPlaya Oct 19 '13 at 6:43
  • So, I think you need to have rendered nodes to see them on the node form, for example a list that renders "node_title triggered_body (nid/last_changed/node_author)" ? If so, you need to follow my answer above. – MichaLueth Oct 19 '13 at 6:58
0

You can use Inline Entity Display module,

Overview

Make available the fields and text properties from referenced entities into the parent entity template and the manage fields display overview. Drupal standard entity display:

Node - title - field body - field reference -> default formatters With IED enabled:

Node - title - field body - field reference -> default formatters - field from field reference: field_name1 - field from field reference: field_name2 - properties of type text from field reference: propertyname1 -etc

and Also you can render it programmatically in tpl file with something like

 // $node = node_load($nid); if you in node $node exists by default
 $values = field_get_items('node', $node, 'yourfieldmachinename');
 $output = field_view_value('node', $node, 'yourfieldmachinename',    $values[0]);
 print render($output);

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.