How can I pass variables from views template to node template? I have a view of contents of a content type. This content type has fields which references entities of another content type (and that in turn references another set of entities of yet another content type).

I am trying to iterate through this view with twig templates.

If I choose to show contents for my format, I can easily access the referenced entities and its fields. My quandary is however, I cannot track what row.content row/index I am in.

If I switch to show fields, I can use the global view results count and I have an effective counter.  However, I cannot seem to be able to access the referenced entities to get the values of the fields.

So far I have not found anything thru searching the net that actually addresses this particular problem. 

I am using the views-view-unformatted template which in turn calls the node--view template. I am unable to 'pass' along the row index from the unformatted views template to node view template.

I already know that this is doable when using fields, but fields is out of the question because of the inability to access referenced entities.

Now there are two possible solutions to this issue:


Show content and somehow track the row.content index between twig templates.
Show fields and be able to actually access the fields of referenced entities.


Anyone have any suggestions?  Thank you.
Possibly use devel and kint modules.

Once both modules are enabled add {{ kint(fields) }} or {{ kint(content) }} to see what your options are for displaying your view's data. If the view wrks successfully then you should be able to display it using twig e.g. if you find field_name in kint and it output's the correct data then add &lt;p&gt;{{ fields.field_name }}&lt;/p&gt; to your template