How do I customize node.tpl to print an entity reference field in a specific format

I have content type called collection that has an entity reference field (multiple) that references another content type called books. One the collection node page, I want to render all of the books as linkable titles, with a button next to them that says “add annotation to book” this will link the user to create a third type (entity) that has a reference field pre – populated.

So my question is this, how do I re- format the books fields of my collection type to meet my use case. So far I have toyed with the following options.

  1. Add a custom node–book.tpl.php file and place code that take the reference field, loops through it, does and entity load on each referenced entity, then adds custom html to the add form of the third content type

  2. Alter the field–type.tpl,php and add it in here – can’t figure out this option because I’m not sure how to retrieve the nid, link, and title from this template.

  3. Create a custom display for my book entity and set the field on my collection to render as this new display (this created other problems, I don’t know if it’s possible to have a separate template for this new display, and this complicated it).


Go to Source of this post
Author Of this post: user379468
Title Of post: How do I customize node.tpl to print an entity reference field in a specific format
Author Link: {authorlink}