Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slug is not unique when template fields are equal #9

Open
madaxen86 opened this issue Feb 10, 2023 · 0 comments
Open

slug is not unique when template fields are equal #9

madaxen86 opened this issue Feb 10, 2023 · 0 comments

Comments

@madaxen86
Copy link

If there are two items in a collection with the same values which are used in the template input the resulting slug is also the same.
But a slug should be unique.
The WP function (docs here: https://developer.wordpress.org/reference/functions/wp_unique_term_slug/)

  1. create the slug according the template
  2. check the DB if / how many items exist
  3. if items exist: add "-" + number to the slug --> myslug-1
  4. repeat check with new slug. increase number if necessary and repeat again...

Maybe you can check if the slug field has been set to unique in Directus and only apply the "makeUnique" function then. So is is more flexible if so users for some reason need multiple items with the same slug. But I think that would be pretty cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant