OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.41k stars 2.39k forks source link

Regenerate autoroute when localizing content #11114

Open gwonen opened 2 years ago

gwonen commented 2 years ago

Is your feature request related to a problem? Please describe.

  1. Set up multiple supported cultures, e.g. 'en' and 'fr'
  2. Create a content type with an AutoroutePart and LocalizationPart.
  3. Configure autoroute pattern to include culture, e.g. {{ ContentItem.Content.LocalizationPart.Culture }}/{{ ContentItem.DisplayText | slugify }} and don't allow the user to regenerate or customize the path.
  4. Create a new content item of your type. It will be created in the default culture with a route matching the pattern, e.g. en/display-text
  5. Create a localization for the item. Since the whole data structure is cloned, the route will get stuck on en/display-text-1 instead of fr/localized-display-text

Describe the solution you'd like

The item's route should be reset when localizing, so that it gets generated with the proper culture and display text. It seems this was discussed in #5083 but never implemented.

Describe alternatives you've considered

As a work-around you can allow the user to regenerate the route but that's not ideal, since the user has to remember to check the option every time they localize an item. Non-technical users might unintentionally break the URL with future edits.

jptissot commented 2 years ago

I like it. This should be the default behavior. Maybe rerun the patterns on all parts that have patterns through a handler.

Skrypt commented 2 years ago

I'd prefer seeing the autoroute path displayed properly in the Razor view itself instead of using a handler. Maybe the work needs to be done in the driver itself.

sebastienros commented 2 years ago

The parts that need to be cleared should implement the localization handler. @gwonen do you want to try and create PR that would do that?

gwonen commented 2 years ago

The parts that need to be cleared should implement the localization handler. @gwonen do you want to try and create PR that would do that?

I don't currently have a development environment set up where I can easily do this, but when I do and this hasn't been resolved yet I'll get back to it.