2

I tried setting up a URL format that takes the hierarchy of a structure into account, but deals with the magic __home__ slug transparently.

So I did this:

{parent.uri == '__home__' ? '' : parent.uri}/{slug}

Which works, but I wanted to tighten it up using the twig ternary ?:, like this:

{parent.uri != '__home__' ?: ''}/{slug}

But that doesn't work at all, seems to choke on the ?: part. Is that a bug, or just a short-coming of the URL format system (not being actual twig)?

1 Answer 1

2

I don't think the ternary operator does what you want it to do. According to this page, the first part of your URL format would return 1 (true) if the parent uri is not __home__, or an empty string if it is.

You could try:

{ parent.uri != '__home__' ? parent.uri }/{slug}

1
  • Yes, of course. Thank you, Commented Feb 20, 2020 at 12:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.