4

In drupal 6 you can create templates to control how node reference fields are output on a content type basis using the suggestion below:

node-nodereference-exampletype.tpl.php

and then output a node reference field that references 'exampletype' nodes in a node template like so:

$node->examplenodereference[0]['view'];

The file naming conventions and output syntax have changed in drupal 7.

Working off the information at this link http://drupal.org/node/998848 I have tried template suggestions like these with no luck:

node--nodereference--exampletype.tpl.php
node-nodereference--exampletype.tpl.php
node--nodereference-exampletype.tpl.php
node-node-reference-exampletype.tpt.php
and so on...

I have tried adjusting the display mode for the field from teaser to full content etc.

I have tried outputting the field with:

print render($content['field_example']);

and

print $field_screening_movie_title;

and variations on the above.

What is the correct way to name a node reference template file in drupal 7? Do I need to use the render function to output a node reference field using the template?

Thanks

2
  • how do you create node reference? with entity reference module? or something else? Commented Jun 21, 2012 at 9:29
  • The node references have been created with the 'References' module drupal.org/project/references
    – Viz
    Commented Jun 21, 2012 at 16:01

1 Answer 1

1

This module has one display formatter named Rendered node, in its setting you can select view mode which referenced node will render in that view mode.

so you can define new view mode and configure referenced node in that view mode

have a look at this post: http://mearra.com/blogs/juha-niemi/drupal-7-custom-node-view-modes

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.