I have a node that has a parent_field (entity reference) that if left empty, that node is a parent. If parent_field has data (ie the nodes parent node name) then I can easily add pathauto in there like so:

[node:parent_field]/[node:title]

However, I would like to be able to select a child as a parent and have pathauto gather this in to the path. Basically getting the parent and child entity reference:

[node:parent_field]/[node:parent_field(child of parent???)]/[node:title]

However, in pathauto (entity tokens included), I don't see how to grab this.

Thoughts?

EDIT:

I was able to do this by chaining entities. @Clive in the comments and a post online helped me figure this out.

I don't understand how you want to fetch a child and how that makes sense, but you can always implement your own tokens using hook_token_info() + hook_tokens() and then you're only limited by what you can do with PHP.
– BerdirDec 13 '18 at 21:30

Thanks @Berdir. Basically one Entity Reference field. The child knows its parent, so how can the grandchild know it's grandparent.
– jasonflahertyDec 13 '18 at 21:43

2

The child knows its parent It doesn't though - all it knows is that it has a referred entity, it doesn't know that it's supposed to be a parent to a child. As far as the system is concerned these could just as easily be sibling relationships or something else. You'll either need custom tokens as @Berdir suggested, or perhaps a rethink to use the taxonomy term entity type instead, which has the concept of lineage you're looking for baked right in
– Clive♦Dec 13 '18 at 22:07

Or in a pinch something like this might work: [node:parent_field:entity:parent_field]. But be careful using nodes for this, it'll be easy enough to end up in an "I'm my own Grandpa" type of situation :)
– Clive♦Dec 13 '18 at 22:15