Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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...
Comments
Comment #1
jmuzz CreditAttribution: jmuzz commentedWell 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) ?