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

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()

|improve this answer|||||
  • Ah right, so this is expected behaviour in a Structure section then. – Clive Portman Jul 5 '17 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 Jul 5 '17 at 18:29
  • In our case that's what we need, so thank you. – Clive Portman Jul 6 '17 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.