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,
    – jishi
    Feb 20, 2020 at 12:26

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.