I created field_data_reference to save data between two or many node. when I view Node detail, I want to display all entities that reference with entity reference. Example:
I created Node: Question Entity, chooses Entity API from Entity Reference Field.
I have a tree
Question Entity ->Entity API (data from Entity ReFerence field).

Beside, Entiry API have reference with Rules, Ctools. So I have a tree
Entity API->Rules->Ctools.

I want to dislay tree in Question Entity as hierachy :
Question Entity->Entity API->Rules->Ctools.
I use to recurse but it is not display as hierachy. Please, tell me how can I do?
Best Regrads

Comments

sinasalek’s picture

I have the exact same question

kaizerking’s picture

Me too!
looking for nested hierarchy support
eg:node1 is referenced by 2 and 2 is referenced by 3, and i want to use dependent filter to get the grand child i.e 3.

ranavaibhav’s picture

Any help on this would be appreciated. Thanks in advance.

mcdoolz’s picture

Hmm... I've found three threads so far, each asking the same question with no answers.

Comically, the Tree (Adjacency Model) project documentation page contains methodology for three separate solutions and a TODO for this particular circumstance.

I do not wish to use View Fields View because performance matters.

Does anybody know of a walkthrough for setting up the Entity Reference hierarchy in views, beyond the first two tiers?

groovedork’s picture

Issue summary:View changes

I've found a whole lot more threads about entity reference hierarchy :-) Not a lof of good solutions though :-(

An answer for the question in #2.

Let's say we have this situation:

Content type A (a.k.a. parent)
- Content type B (a.k.a. children) (with entity reference field that points to A)
-- Content type C (a.k.a. grand-children) (with entity reference field that points to B)

Finding the child of a child, or the parent of a parent, can be done in views.

Let's say we want to find all the grandchildren C of a particular parent A.
- Create a basic view (in my case I like using Entity Views Attach, but you could also make a block or a page)
- Under advanced, add a relationship, and choose "entity reference" as the type. In this example we are starting from A, so select the reference 'down' to the children, B. You get two choices (the content referencing, and the content being referenced), so think for a second and select the right one. On the configuration page you should check "this relationship must exist". This will limit/filter the selected content to only content that has this relationship.
- Then, add a second relationship. At the configure page select the relationship you just created from the dropdown. That will make the referenced content (B) the startingpoint for the next and final jump to the C content.
- Add the fields you want to display, and in its configuration choose the second relationship you made from the dropdown. That way you're basically saying "I want the field of the content that is two jumps away". The preview should now show all the grandchildren of all the parent pages you may have made.
- For the finishing touch you can add a contextual filter, so you can select a single A startingpoint. Select NID as the field you want to filter on. This time don't select a relationship.
- Test your creation: try previewing with the node-ID of a startingpoint.

Now, visualising the tree on a page, that's more difficult. It seems like the best solution is to use Views Field View and recursively generate the tree, perhaps in combination with the Views Tree module (haven't tried it yet). Choose "provide default value" and choose "content ID from URL".

My forum posts in which I've asked the same question:
https://www.drupal.org/node/2498977
https://www.drupal.org/node/2502693