In Drupal 6 with Views Attach we were able to see the attached view in the $node object, and we were able to print it out in a node template independently of other fields.

In Drupal 7 with EVA, the attached view does not appear in the $node object or the $content array. In previous development versions of EVA, the attached view did appear when render($content) was printed, but did not actually appear in the $content array itself.

  1. It appears that EVA currently does not support custom content types. Although the view does indeed attach to a custom content type and is listed with all other fields under "Manage Display", the view doesn't actually display when viewing a node. It seems like this would need to be fixed first. Issue already logged here: #1345228: EVA with custom entities
  2. Is there a dpm() command that can be used in a node template to discover where the attached view is located?
  3. Is there a PHP snippet that can be used to render an attached view in a node template?

Comments

FR6’s picture

@Fr0s7 in version 7.x-1.1 and Drupal 7.10 it worked for me.

  • I attached the view to a node.
  • The view is listed in the "Manage display" tab of my custom content type.
  • The view is displayed when I'm viewing the node.

And if I want to change the layout of my node with a custom template file (node--mycontenttype.tpl.php), I have access to the view in the $content array variable and I can render it where I want with render($content["myview_entity_view_1"]).

calhemp’s picture

thanks for this clue. very useful to me.

Fr0s7’s picture

EVA is working much better these days.

@FR6: Thank you very much for the code snippet. I am indeed able to print out a single entity view attachment using the following:

<?php print render($content["my_view_machine_name_entity_view_1"]); ?>

NOTE: It's important to replace any dashes in the view machine name with underscores. You do NOT need to prepend your view name with 'view_' like Drupal does in markup.

Fr0s7’s picture

Status: Active » Closed (fixed)
deelite’s picture

Issue summary: View changes

In my case it doesn't work. I use

<?php print render($content["image_gallery_entity_view_1"]); ?>

where 'image_gallery' is the machine name of my view. I have 2 displays of type 'EVA field'. Neither entity_view_1 nor entity_view_2 are working.

I use version 7.x-1.x-dev of EVA.

Can anybody help?

Update: there was a problem with my view. With a new view it works as expected.

maxplus’s picture

For me this works; I only have one EVA display in my view:

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

I'm using EVA 7.x-1.4