Custom Path Alias with Initial Letter as Token For various reasons, I need to change my custom path alias for a taxonomy type as follows...

FROM:
/composers/aardvark

TO:
composers/a/aardvark

So I'm looking at either creating a custom token, or a computed field to figure out the first letter of the term and feed into the pathauto module...

I'm having trouble figuring out either... Could anyone suggest the correct code to use for either of these? Most of the examples I am finding are node specific, and not taxonomy term specific...

The reason I'm looking to do this, is to provide a contextual filter to a views block... But if anyone could suggest a good way to pass 'a' from 'aardvark' into the block - so that both of these paths passes the same contextual filter, that would be equally good!

/composers/a

/composers/aardvark

Thanks in advance for your help!
There are many ways to achieve this, as you said.

The less-coding way I see is to use Custom Token and create for each node a token using the following code :

return substr($node-&gt;title, 0);


Then you use this token in your URL alias pattern like [yournewtoken]/[node:title].

If you have a multi-lingual site, the first letter might not be the same in all languages, you may update this code to fit this.