In using URL aliases, is there a way to have conditional token usage? An example of what I'm looking for is:

  • I have programs on my page, each having their own unique program code.
    • By default, say my program is General Arts, the URL alias would be /programs/general-arts
  • However, sometimes, the programs may have multiple program codes due to being taught in different locations.
    • What I'd like (if it's possible at all) is when I create another program with the same name (let's use General Arts again for example), except it has a different program code, I'd like the URL alias' to then be /programs/general-arts-C123 for the first one and /programs/general-arts-D321 for the second one because they're the same program, just different program codes (due to being taught in different locations). Pretty much appending the course code to the end of the URL to distinguish the two.

Or is the only way to do something like this is to manually override the URL alias and put the custom URL in?

  • 1
    Yes, the simplest answer is to define your own token and there you can do whatever you want. If I'm understanding what you want correctly then your problem is that initially, you only have one curse, so you wouldn't add the course code, but then later you'd add a second and as a result, you'd need to not just return the current alias accordingly but also change the existing one? That doesn't work so easily, you might want to just always include it.
    – Berdir
    Oct 1, 2018 at 6:32

1 Answer 1


You can just return an empty string with your custom token.

Or you could make your custom token return the title and course code and handle it that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.