Generate a short alias on entity form submit

Created on 22 November 2023, 10 months ago
Updated 27 November 2023, 10 months ago

When creating or editing an entity, I would like to be able to toggle on or off a switch, which when enabled, will trigger the assignment of a short alias upon form submission. If an alias already exists, I should still have the option to generate a new short alias, and an additional (but disabled) text input should indicate the most recently generated short alias for this entity.

I imagine this being very similar to the form element provided by pathauto:

I intend for short aliases to be generated via a sequence. Creating on form submit, rather than on form load will help to prevent duplicate aliases.

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @MegaKeegMan
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    In order to generate the aliases in a sequence, I suspect that I will need to create a new database table that tracks an id of each alias. I am trying to consider possible ways to avoid creating a new table. With what I have done so far, a short alias is just a redirect, given the type "short alias". One potential solution would be to just encode the short alias based on the assigned redirect id. One issue with this approach is that a large proportion of redirects may not be short aliases, meaning that I would be reducing the number of low character aliases created. This makes me lean toward creating a table that stores short aliases, using the primary id of that table, and then including a reference to the redirect from this table. This would mean that the short alias field would be more of an entity reference to a redirect entity.

  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    @wolcen emphasized for me that building urls sequentially will not be very random. And I admit that the base 32 encoding of 1 being 1 makes for some very not random looking short aliases. As such, I am now leaning away from sequential short aliases, and am instead thinking of just randomly generating a number to encode. I will need to at some point choose a min and max number. Otherwise, I just need to make sure that if a randomly generated alias is taken, that a new one is produced without an error.

  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    This is working just fine. I would appreciate suggestions for cleaner code and for improvements to error handling.

  • Status changed to Fixed 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024