diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutorouteContentLocalizationHandler.cs b/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutorouteContentLocalizationHandler.cs new file mode 100644 index 00000000000..9396bba94d1 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutorouteContentLocalizationHandler.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using OrchardCore.Autoroute.Models; +using OrchardCore.ContentManagement; + +namespace OrchardCore.ContentLocalization.Handlers; + +public class AutorouteContentLocalizationHandler : IContentLocalizationHandler +{ + public Task LocalizedAsync(LocalizationContentContext context) => Task.CompletedTask; + + public Task LocalizingAsync(LocalizationContentContext context) + { + if (context.ContentItem.Has()) + { + // Clearing the AutoroutePart path to regenerate the permalink automatically. + context.ContentItem.Content.AutoroutePart.Path = null; + } + + return Task.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs index e537e8fbe35..ab27925eda0 100644 --- a/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs @@ -14,6 +14,7 @@ using OrchardCore.Autoroute.Settings; using OrchardCore.Autoroute.Sitemaps; using OrchardCore.Autoroute.ViewModels; +using OrchardCore.ContentLocalization.Handlers; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.GraphQL.Options; @@ -132,4 +133,13 @@ public override void ConfigureServices(IServiceCollection services) { services.AddShapeTableProvider(); } + + [RequireFeatures("OrchardCore.Autoroute")] + public class AutoPartStartup : StartupBase + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddScoped(); + } + } } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs index 353bbf81cbc..84f6a7b5bdd 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs @@ -52,6 +52,7 @@ public override void ConfigureServices(IServiceCollection services) public sealed class ContentPickerStartup : StartupBase { private readonly IShellConfiguration _shellConfiguration; + public ContentPickerStartup(IShellConfiguration shellConfiguration) { _shellConfiguration = shellConfiguration; @@ -61,10 +62,12 @@ public override void ConfigureServices(IServiceCollection services) { services.AddDisplayDriver(); services.AddLiquidFilter("switch_culture_url"); + services.AddNavigationProvider(); services.AddScoped(); services.AddSiteDisplayDriver(); services.AddSiteDisplayDriver(); + services.Configure(options => options.AddInitialRequestCultureProvider(new ContentRequestCultureProvider())); services.Configure(_shellConfiguration.GetSection("OrchardCore_ContentLocalization_CulturePickerOptions")); }