dimitrov-adrian/directus-extension-wpslug-interface

slug is not unique when template fields are equal

madaxen86 opened this issue · 0 comments

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.