This project is read-only.

Override the Delete ContentItem Action

Topics: Customizing Orchard, General, Troubleshooting, Writing modules
Dec 7, 2011 at 12:00 AM

I'm looking at overriding the delete action in my module to provide an 'Are you sure?' page.

Following the blog module I have created my Controller action and created the appropriate RouteValueDictionary for the Metadata.RemoveRouteValues by overrideing the GetItemMetadata in my parts handler.  However the url for the delete link in the admin interface remains pointing at the default Contents area.

I have looked at the code that generates the link in Content.SummaryAdmin.cshtml and it doesn't seem to use the action stored in the Metadata, its hardcoded.  To confirm this I have debugged the Blog module and the Remove action on the BlogAdminController is never called when deleting a blog.

Just wanted to see what people think before I raise a bug.

Dec 7, 2011 at 12:26 AM

Looks like a bug, it should definitely use the metadata.

Another way to have the confirm delete would be Javascript - the delete link has a HTML attribute of itemprop="RemoveUrl UnsafeUrl" - you could use that to target the button with jQuery and pop up a warning.

Dec 7, 2011 at 1:09 AM

What we've always wanted but never had time to implement yet is a Netflix kind of delete (or GMail for that matter) where ther delete is done right away but you get a chance to revert it.

Dec 7, 2011 at 1:13 AM

@Bertrand: You can't revert it if it's not a ContentItem, e.g. Rules, Layers, ...

Dec 7, 2011 at 1:14 AM

Currently you can't. It's not a small work item.

Dec 7, 2011 at 9:37 AM

@pete Yeah I think I will be going down this route, thanks.  I have also raised a work item for the bug

@bertrand That sort of implementation would be cool, I suppose it goes on the 'nice to have' list ;)