The Entity token module is part of the Drupal Entity Module package, it provides lots of new tokens to use everywhere that tokens are currently available. It does this by being aware of the structure of fields on entities and exposing extra options for fields that reference entities. For example, it allows you to use many more tokens about taxonomy terms added to content.
To see this in action we'll consider a simple example.
Say that we have articles about birds on our site, suppose further that each article is about a specific species of bird. We make the simplification that each species is part of a single family of species. All that boils down to us having a 'Species' vocabulary that looks like this:
We then add a taxonomy term reference field to our article content type,
field_species and we set it up to use our vocabulary. We ensure that our content editors only create articles about a specific species and not a family of species.
What we'd like to do is have nice URLs like the following:
For an article about Rooks.
We can use the Pathauto to set up nicer URLs, but Drupal core doesn't provide the tokens that we need. We need to get the root term (top level parent) of the selected species (which is the family) and add that to our path. Enter Entity Token, it knows that the
field_species field contains a taxonomy term, and that taxonomy terms have a root term.
You can explore the list of tokens that Entity token provides:
And we can see that we have all the tokens we need. So we can set up Pathauto using the following pattern:
Then if you create an article, you will see that the URL path generated is like the one we wanted above. Cool!