What’s the best way to automatically create a 410 (gone) error code when a resource is deleted? Can’t find an extra that does this and it could be useful search engine indexing purposes rather than returning a 404.
I was thinking of trying to write a plugin or fork of some other extra to use OnDocFormDelete to do this but wanted to check that someone else hasn’t already done this and I just haven’t been about to find it. Or maybe there’s a better way to do it?
Thanks.
I don’t know of any extra that does this.
In my opinion this event won’t work. It gets invoked when a resource is deleted in the manager.
My guess is that you have to use the “OnPageNotFound” event. Then in a plugin, check if a deleted resource exists with the requested URL.
(This will only work if you don’t remove the deleted resources completely in the trash manager. Otherwise you have to keep a list/database-table of deleted resources and their URLs.)
Thanks for the input. So I think for the way for it to function as I envision it would be a plugin that triggers on OnDocFormDelete to log the deleted resource in a database table, then a second OnPageNotFound plugin that checks that table and issues a 410 if needed. Then some form of a manager in the extras menu to manually edit the deleted resources table if needed. Time to do some reading for me.
No need to write two plugins. You can handle different events in the same plugin.
If you are not familiar with Ext.js, I recommend using MIGXdb (part of the MIGX extra) to create the database table and the CMP (custom manager page) for editing it.
The resource has a field uri
that you’ll have to save to the new table for the look-up.
Thanks for the suggestions, I’m familiar with Migx and will look into CMPs.