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. 


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
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.
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).
I think your information architecture in inverted. It sounds more like Book is in Collection rather than Collection has Book. In other words Collection is an attribute of Book, not the other way around. It would be easier to put the reference field on the Book content type, and create a view of all Book s referencing a Collection to display on the Collection content type, using a Contextual filter to limit the list. No changes required to template files!

Then using the Prepopulate module, you can use the $_REQUEST variable to set your field_book value in the new node, and it is a simple matter to add  the Content:Nid to the view and rewrite the field to create the link.

First, install and activate the Prepopulate module. Then put your Entity Reference field on the Book content type and limit it to the Collection content type. Then add an Entity reference field to the Annotation content type and limit it to Book. In other words, you are identifying the Book the annotation belongs to.

Then create a view of Content (Book) with a display type of Block. In the views configuration, create a Contextual filter on Content: Collection (field_collection) and configure it to Provide default value and select Entity ID from URL.

Add the field Content:NID and configure the field. Select Rewrite results  and check Rewrite the output of this field. In the text box enter something like:

&lt;a href="/node/add/annotation?edit%5Bfield_collection%5D%5Bund%5D%5B0%5D%5Btarget_id%5D=[nid]"&gt;Annotate this book&lt;/a&gt;


(%5B = "[" and %5D = "]"). The actual link code may vary depending on how you have implemented the Entity reference field in your content type. The module has good documentation.

Save your view and under /admin/structure/block find the block created by the view and set it to display only on pages of type Collection.

The block will then display a list of book titles (linked to their content) and the custom link to add an Annotation page with field_book prepopulated, and limited to those books which reference the Collection being viewed.