I have an idea to create urls for entries that can't be guessed, but are automated without any extra effort from the content creator/editors. The intention is for the URL not require any authentication, but not be "guessable" just because you have another similar URL.

My thought was to use the Entry URL Format field to automate this. I tried the following but it didn't work as expected:

documents/{ (id * 1234567) | number_format(0, null, '-') }

I assumed I could use any twig syntax here due to the description/label for the input field:

What the entry URLs should look like. You can include tags that output entry properties, such as {slug} or {postDate|date("Y")}.

So, is it possible to do what I'm trying? What's the correct twig syntax here?

1 Answer 1


After chatting with The Honorable Brad Bell I learned that the sample tags in the field's label are showing some shorthand references to a few variables. (The {slug} reference for example.)

All I needed to do was use the object object to fully utilize twig tags/filters/etc. Here are a few ways to achieve what I was aiming for:

{% set num = (object.id * 1234567) | number_format(0, null, '-') %}documents/{{ num }}

or slightly more concise code:

documents/{{ (object.id * 1234567) | number_format(0, null, '-') }}

Also, thanks to carlsc for sharing the documentation on this feature. Reference: https://craftcms.com/docs/sections-and-entries#dynamic-entry-titles.

Happy Dynamic Titling and URLing.


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.