Skip to content

slug is not unique when template fields are equal #9

@madaxen86

Description

@madaxen86

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions