printing formatted content of a View field in Drupal 7custom template

asked Aug 30, 2013 in Website Builder by carebare (1,420 points)
I want to print the content of  some Viewfield content in my Drupal custom template. They’re separate blocks inside the same View.
This I the code I tried
<?php echo $node->myfield_fie1[0]['view']; ?>
<?php echo $node->myfield_fie2[0]['view']; ?>
But that didn’t work
Can anyone please help me print this?

1 Answer

0 like 0 dislike
answered Aug 30, 2013 by RalphK (5,800 points)
If you are using a view in your template, you can use the view_embed_view() like this
<?php print views_embed_view('myview','block1', $node->nid); ?>
<?php print views_embed_view('myview','block2', $node->nid); ?>