change permalink when title changes

5 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: March 9, 2022   (RSS)

By kitsguru - February 23, 2022 - edited: February 23, 2022

Is there a simple way to detect when the title or another field of a record changes and have the permalink also updated?

I have a custom plugin that adds the category label to the permalink so when either the title or category changes, I want the permalink to update without needing to clear it manually.

Secondly the update permalink table command does not take the category into account. How can I link my plugin to the update table permalink?

Jeff Shields

By kitsguru - March 1, 2022 - edited: March 1, 2022

A hook system in the permalink plugin would be very useful. OR allow 'category:label' in autopopulate_fromFields

Jeff Shields

By daniel - March 9, 2022

Hey Jeff,

Thanks for posting your update!

Another similar idea would be to use the record_presave hook to check to see if a field has been changed and similarly empty the permalink from the $_REQUEST array. Since the record_presave hook provides the old record's data (new data is in $_REQUEST), it would be relatively simple to compare the new and old values. There's an example included in the Permalinks readme.txt for creating custom permalink formats with a plugin - this should have most of the info required to set this up.

I'll note that we do have "category:label" support in the works for an upcoming release of the Permalinks plugin. Keep an eye out for this! Also, If you have any specific hooks you think would be useful within the plugin, let me know and I can bring them up for consideration.

Thanks,

Daniel
Technical Lead
interactivetools.com

By kitsguru - March 9, 2022

One thing I would like to see is being able to use a / in some cases when using 2 fields.

So ”city address” instead of ‘mycity-123-anywhere’ could be ‘mycity/123-anywhere’

Jeff Shields