1

I have a special case where the URL needs to be defined from within the entry itself. I have a dropdown that I want to populate with the URLs as values.

Can the dropdown value be used to generate the URL? I can not use custom site URLs because the customer/user needs to see the URL themselves from within the entry.

The entry is a channel.

So let's say the dropdown has a label called "Monkey". Then I want the URL to be /monkey/article-slug.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
Hopstad
  • 25
  • 4

1 Answers1

3

In the section settings, you can specify a dynamic entry URI format.

As the docs say, this box is in fact a mini Twig template, and is preloaded with the element being saved (accessible as object) and its custom fields (accessible directly by their handles). Good to know that you can also use a shortcut syntax with single braces instead of double ones here.

So in your case you'd want something like:

{slugPrefixFieldHandle ? slugPrefixFieldHandle ~ '/' ~ slug : slug}

James Smith
  • 5,154
  • 14
  • 15