I think my experiments were successful. After a very deep dive into uid addon and the way fields are structured and validated, I decided to allow admin to customize the required page name change. Some people will like a fully-written UID appended to page name, with suffix and prefix. Some people will need only a basic core number in the page name.
The solution to customization is in writing a validator with argument in the editable field's definition. Nothing can be simpler for a designer - just write in a validator name. Here I am taking an original field definition with UID by KK and add a custom validator there -
- Code: Select all
desc='will be generated automatically'
Validator's name is my custom PHP function and val_separator
is used to separate, obviously, validator's name from its argument (arbitrary parameter passed to validator function). I chose the argument to be a full
or any other word (short, etc) - to indicate whether we take UID in the full form as in AT-0000458-20200521 or its short form 0000458 or, simply, 458.
So, the argument 'full' in validator makes the page 'My Product' name look like my-product-at-0000458-20200521
. If such form is not required, then a line validator='pagename_plus_uid'
is enough - this makes the page name to be my-product-458
If you have any questions along the writing your own solution - whether it is a validator without event-hooking or just a quick hook on mentioned event, feel free to post questions to this thread. If you don't have time to do the dirty work I will gladly share tested polished and approved code in PM ($10 will make my day).