I can't get my view to embed using Views Attach. I have two content types with one as a nodereference using CCK.

I have a noderef argument: field_newreview_nid
The Display id: node_content_1
View name: Reviews

I've tried numerous methods in the tpl:

$view = views_get_view('Reviews');
$args = array('field_newreview_nid');
display = $view->execute_display('node_content_1', $args);
print $display['content'];

I've tried the shorthand:

views_embed_view('Reviews', 'node_content_1', 'field_newreview_nid');

Plus a few more I've seen searching Google and drupal.org. No matter what the view won't show up. Can anyone tell me what I'm doing wrong or even the exact snippet I need to get it to show up? Thanks.

Comments

RKS’s picture

I've been searching around the last week and still haven't found anyone who knows this answer.

Crell’s picture

Status: Active » Fixed

Views Attach is not intended to be used with custom code. Don't do that. :-)

If you want your view to display on nodes of type "Foo", then check off that node type in the display configuration and save the view. Then go to the Fields tab of node type Foo and you'll see a new grayed out pseudo-field for the View you just created. Drag and drop that to the order you want.

You should not be writing any custom code here at all.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jrstmartin’s picture

views_embed_view('Reviews', 'node_content_1', implode(',', $field_newreview_nid));
bandt’s picture

Try this:
print $node->content['reviews_node_content_1']['#value'];