I have a custom node (article) template file working fine, and I want to show related nodes (events) in their teaser format. I have been doing this in my node--article.tpl.php file like this:

foreach ($field_related_event as $event_node){
    print render(node_view(node_load($event_node['nid']), 'teaser')); 

I wanted to add a second teaser format for events (teaser_fancy) and downloaded "Entity view modes" thinking I would be able to do something like this:

foreach ($field_related_event as $event_node){
    print render(node_view(node_load($event_node['nid']), 'teaser_fancy')); 

But now I read that node_view can only use teaser and full, and it's probably not a good idea to render relationships in my template this way. What's the recommended way to go about this? Should I create an Events Fancy view and use views_embed_view instead?


A valid "view_mode" should work with node_view and that approach looks reasonable.

However, if it's proving problematic, you can also use Views with views_embed_view


print views_embed_view('viewname', 'display_id', $node->nid); // node id contextual filter
  • Thanks that's what I suspected. Do you think there is a big downside to using rendering the way I am is I want all related items? – summer Jan 23 '13 at 16:18

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.