i am trying to set the url format for some entries to include the category slugs set for it within a category entry field - i can get the first one like this


but cannot figure out how to get the second one (the 2nd one is optional and is a sub-cat of category1 also so not sure how to do some optional logic for it within the 'Entry URI Format')

so the url could be category1/slug OR category1/catgeory2/slug

Any ideas anyone? Thanks

1 Answer 1


You can use .all() to get all selected categories in order. Since the URI format is a Twig template, you can use some Twig filters to output all selected categories as path segments:

{{ eventCategory.all()|column('slug')|join('/')/{{ slug }}

The column filter will extract the slug property from the array of entries, and join will join the array of slugs to a single string separated by slashes /.

This will result in category1/slug for an entry with only one category, and category1/category2/slug for entries with two categories. It will also work for any number of selected categories (though you may want a different format in this case).

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.