1

I have 2 content types: book and author.

This is the structure:


enter image description here

I want to use (print) some fields of author content type inside the node-book-tpl.php.

How can I do that? Is there a method to print referenced entity's fields like <?php print render($content['field_author']); ?> etc.?

Note: I tried the Inline Entity Display module but because I want to do this with custom node-book.tpl.php it doesn't work for me.

  • 1
    Use the stored uid within the reference field to load the corresponding entity and render whichever field you want. For the image field use theme_image – mchar Jun 20 '16 at 10:06
  • Thanks for the comment. Could you please give more details about uid? – herci Jun 21 '16 at 9:11
1

If there is no compelling reason to render the fields from within the template, you could simply:

  1. choose a certain view mode for your author content type, say: Token, and make it show only those fields you want to be visible in the book node;
  2. set the display of the field referencing the author node from the book node to "Rendered entity" / "Rendered as Token".
0

As you say author is also a content type. Then you get author content node id on book content.if get node id then use node_load($author_nid); to load author node.print_r() load node and print fields you want to show.

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.