1

I know Craft appends slugs with -1 if they already exist but I'm working on an app where the addition makes things awkward for us (we have to match the slug to a third-party service). I was under the impression they had to be unique but it seems you can edit an entry and change the slug to be the same as one that already exists.

This could be a good workaround for us, but I want to check whether it's a bug that's likely to get squashed or deliberate behaviour.

1 Answer 1

1

Technically it's a combination of the element's slug plus URI that is required to be unique (on a per-locale basis).

You can see the logic used and where it's enforced at the code level in ElementHelper::setUniqueURI()

3
  • Ah right, so this is expected behaviour in a Structure section then. Commented Jul 5, 2017 at 9:25
  • Assuming the nested entries setting for that Structure is set to {parent.uri}/{slug}, then yeah, there's a good chance it'll always be unique (unless they're on the same level in the Structure).
    – Brad Bell
    Commented Jul 5, 2017 at 18:29
  • In our case that's what we need, so thank you. Commented Jul 6, 2017 at 8:28

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.