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
<cms:editable
type='uid'
name='my_uid'
label='Invoice Number'
desc='will be generated automatically'
search_type='integer'
begin_from='425'
min_length='7'
prefix='AT-'
suffix='-[YYYY][MM][DD]'
validator='pagename_plus_uid:full'
val_separator=':'
/>
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.