Using Collection with FURLS & Getting Duplicate aliases. Is there a fix?

Would like to be able to add the [[*id]] to the FURL / alias when using “Collections”. Can this be done via “Collection View” or otherwise?

So ultimately, instead of
mydomain.com/parent/child.html

I would like something like:
mydomain.com/parent/child-[[*id]].html

Maybe take a look at this recent topic:

1 Like

I did see that but probably need more clarity on adding that code with the default code on “OnDocFormSave”

In the manager you can add custom plugins that run some PHP code when a MODX event occurs.
In the “Elements” tab (beneath “Snippets”) add a new plugin and change to the tab “System Events” to select the event, when your plugin should run.

The event OnDocFormSave fires after a Resource is saved in the manager via the editing form.
Here you can make changes to the saved resource.

Copy the code from the other thread (linked above) to the field “Plugin code (php):” in the tab “Create/edit plugin”.
Then adapt the code to your needs. Maybe add a check, so that it only runs for resources with a certain template, etc.

Thank you for describing these steps so clearly @halftrainedharry. I have done the following and when a resource is saved / published, I have to change the alias so that it doesn’t match a previous alias. Once it finally saves, the url for that collection is just the root “/’”. What am I missing?

Does it work if you remove the 3 backticks at the end of the code.

$resource->save();

instead of

$resource->save();```

(This is just some formatting error. The backticks shouldn’t be there.)

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”.