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.

2
  • 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
    Commented Jun 20, 2016 at 10:06
  • Thanks for the comment. Could you please give more details about uid?
    – herci
    Commented Jun 21, 2016 at 9:11

2 Answers 2

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 and acknowledge you have read our privacy policy.

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