adminorchardcmsorchardcms-1.7orchardcms-1.8

Autoroute Bulk operations in Orchard


If you customize an autoroute part you have the option to recreate the url on each save.

The help text under this option says:

"Automatically regenerate when editing content This option will cause the Url to automatically be regenerated when you edit existing content and publish it again, otherwise it will always keep the old route, or you have to perform bulk update in the Autoroute admin."

I have digged all around but I cannot find anywhere an "Autoroute admin".

Is it really there?

It was a proposed feature never implemented?

Any idea to do a bulk update even without an Admin page?

Thanks

EDIT after @joshb suggestion...

I have tried to implement a bulk operation in my controller.

  var MyContents = _contentManager.Query<MyContentPart, MyContentPartRecord>().List().ToList();

  foreach (var MyContent in MyContents) {
        var autoroutePart = recipe.ContentItem.As<AutoroutePart>();
        autoroutePart.UseCustomPattern = false;
        autoroutePart.DisplayAlias = _autorouteService.GenerateAlias(autoroutePart);
        _contentManager.Publish(autoroutePart.ContentItem);
  }

In this way it recreates all aliases for the types that contain the given part MyContentPart. With some more work this code can be encapsulated in a command or in a new tab in Alias UI. After finished the current project I'm doing I will try that...


Solution

  • You could create a module and implement a command that does a bulk update. Shouldn't be too much work if you're comfortable creating modules. You'll need to implement DefaultOrchardCommandHandler and inject IContentManager to get all the parts you're interested in.