As far as I can see the entity_id field is not available as a view field. I would like to use the host entity as a filter for my listing of field collection items.

I have a bit of experience in writing the views integration mapping stuff, so I guess it could be fairly easy to provide views integration for the entity_id field as well. Can someone give a hint, how exactly this could be done?

Thanks,
Walter

Comments

valderama’s picture

Project: Views Field View » Field collection

ups, orignially posted the issue in the wrong queue

AndrzejG’s picture

Did You try the EVA (http://drupal.org/project/eva)? I mean EVA holds only Collected fields and is attached to the host entity as a bundle.

tim.plunkett’s picture

Status: Active » Postponed
h.arefmanesh’s picture

I also want to filter field collection item by host entity id.
can anyone help me Please?

charlie-s’s picture

Same issue. Sub.

charlie-s’s picture

You can include the field_collection ID as an excluded field and then use Views PHP to print a PHP field with something like this:

<?php
$entity = entity_load('field_collection_item', $row->field_collection_item_id);
$host_entity = $entity->hostEntity();
?>

Now $host_entity is your node or whatever the field_collection is attached to. Thus $host_entity->nid would be your node id.

zunaeid’s picture

This is working for me

$field_collection_item = entity_load('field_collection_item', array($row->field_collection_item_id));
$host_entity = $field_collection_item[$row->field_collection_item_id]->hostEntity();
jmuzz’s picture

Issue summary: View changes
Status: Postponed » Fixed

The suggested solutions should work as far as I know.

Status: Fixed » Closed (fixed)

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