I was not able to find a simpler API that uses a field collection item id to get the node nid containing the field collection item. Currently, the only way I could find is by loading field collection via entity_load.

$model = entity_load_single('field_collection_item', $model_id);
$node = $model->hostEntity();
echo $node->nid;

Is there a simpler way to achieve this?

Source of code: http://drupal.stackexchange.com/questions/62877/get-node-id-of-field-col...


jmuzz’s picture

Issue summary: View changes
Status: Active » Fixed
$model = field_collection_item_load($model_id);
$node = $model->hostEntity();
echo $node->nid;

Well it isn't much simpler but it's the best I think it can be.

Is there a simpler way to get an author of a node when you only have a nid (for example) ?

Status: Fixed » Closed (fixed)

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