I am just hoping to get the node ID of the parent node in a field-collection-item--name.tpl.php
template file.
So if my parent node name is mypage in which I have child fields of field-collection-item--name.tpl.php, I just want to access the Node ID of the parent page (mypage) in field-collection-item--name.tpl.php.
Is it possible?
Apparently somewhat yes. If I do this, I get details on the parent node. The only problem is that that data is protected. The output of this line is pasted below. All I want is [vid] value (i.e. 120)
$var = $content["field_image_title"]["#object"];
print_r ($var);
Output of above line
FieldCollectionItemEntity Object
(
[fieldInfo:protected] =>
[hostEntity:protected] => stdClass Object
(
[vid] => 120
[uid] => 1
[title] => My Parent Page Name
[log] =>
[status] => 1
[comment] => 1
[promote] => 0
[sticky] => 0
[vuuid] => f3c2f63d-5d86-4d94-98f3-8a1ba76ce1f9
[nid] => 120
[type] => subpage
[language] => und
[created] => 1408623334
[changed] => 1408640101
[tnid] => 0
[translate] => 0
[uuid] => 486dead0-4f72-45a3-988c-64512e6b91de
[revision_timestamp] => 1408640101
[revision_uid] => 1
Any help on how I can get this vid value in this protected array?
Thanks.
Objects
and notArrays
. It's not recommended to place business logic into template files whose purpose is for view output.