Add unique suffix to friendly URLs

For pages in a collection I need to find a way of suffixing the alias with say the resource id so it allows for resources with the same name but a different alias. Is that at all possible?

This should be possible, but you have to set the “Resource Alias” field manually (and not rely on the automatic creation of the alias based on the pagetitle).


If you want to automate it, you probably have to create a custom plugin (event OnBeforeDocFormSave) and set the alias there (if it’s empty).

You pointed me in the right direction and after some searching I found a plugin on an old thread and this does the job - set to OnDocFormSave…

/* act only on new resources */
if ($mode != modSystemEvent::MODE_NEW) return;
$pageTitle = $resource->get('pagetitle');
$code = $resource->get('id');
// $code = date("Y.m.d-H:i:s");
$alias = $resource->cleanAlias($pageTitle);
$newAlias = $alias . $code;
$resource->set('alias', $newAlias);
$resource->save();```

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.