diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs index f362d3a8ffd..8e1356b774b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.DependencyInjection; -using OrchardCore.Admin.Models; using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Theming; @@ -31,7 +30,6 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddDeployment(); - services.AddDisplayDriver(); services.AddDisplayDriver(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Drivers/ToggleThemeNavbarDisplayDriver.cs b/src/OrchardCore.Themes/TheAdmin/Drivers/ToggleThemeNavbarDisplayDriver.cs similarity index 89% rename from src/OrchardCore.Modules/OrchardCore.Themes/Drivers/ToggleThemeNavbarDisplayDriver.cs rename to src/OrchardCore.Themes/TheAdmin/Drivers/ToggleThemeNavbarDisplayDriver.cs index 33e84a389cd..e0a20614a24 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Drivers/ToggleThemeNavbarDisplayDriver.cs +++ b/src/OrchardCore.Themes/TheAdmin/Drivers/ToggleThemeNavbarDisplayDriver.cs @@ -3,7 +3,7 @@ using OrchardCore.DisplayManagement.Views; using OrchardCore.Settings; -namespace OrchardCore.Themes.Drivers; +namespace OrchardCore.Themes.TheAdmin.Drivers; public sealed class ToggleThemeNavbarDisplayDriver : DisplayDriver { @@ -18,7 +18,6 @@ public override IDisplayResult Display(Navbar model, BuildDisplayContext context { return View("ToggleTheme", model) .RenderWhen(async () => (await _siteService.GetSettingsAsync()).DisplayThemeToggler) - .Location("Detail", "Content:10") .Location("DetailAdmin", "Content:10"); } } diff --git a/src/OrchardCore.Themes/TheAdmin/Startup.cs b/src/OrchardCore.Themes/TheAdmin/Startup.cs index a045d43e39e..ef496f3b4f5 100644 --- a/src/OrchardCore.Themes/TheAdmin/Startup.cs +++ b/src/OrchardCore.Themes/TheAdmin/Startup.cs @@ -1,7 +1,10 @@ using Microsoft.Extensions.DependencyInjection; +using OrchardCore.Admin.Models; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Html; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Modules; +using OrchardCore.Themes.TheAdmin.Drivers; namespace OrchardCore.Themes.TheAdmin; @@ -16,6 +19,7 @@ public Startup(IShellConfiguration configuration) public override void ConfigureServices(IServiceCollection services) { + services.AddDisplayDriver(); services.AddResourceConfiguration(); services.Configure(_configuration.GetSection("TheAdminTheme:StyleSettings")); } diff --git a/src/OrchardCore.Themes/TheTheme/Drivers/ToggleThemeNavbarDisplayDriver.cs b/src/OrchardCore.Themes/TheTheme/Drivers/ToggleThemeNavbarDisplayDriver.cs new file mode 100644 index 00000000000..331df2d008c --- /dev/null +++ b/src/OrchardCore.Themes/TheTheme/Drivers/ToggleThemeNavbarDisplayDriver.cs @@ -0,0 +1,23 @@ +using OrchardCore.Admin.Models; +using OrchardCore.DisplayManagement.Handlers; +using OrchardCore.DisplayManagement.Views; +using OrchardCore.Themes.Services; + +namespace TheTheme.Drivers; + +public sealed class ToggleThemeNavbarDisplayDriver : DisplayDriver +{ + private readonly ISiteThemeService _siteThemeService; + + public ToggleThemeNavbarDisplayDriver(ISiteThemeService siteThemeService) + { + _siteThemeService = siteThemeService; + } + + public override IDisplayResult Display(Navbar model, BuildDisplayContext context) + { + return View("ToggleTheme", model) + .RenderWhen(async () => await _siteThemeService.GetSiteThemeNameAsync() == "TheTheme") + .Location("Detail", "Content:10"); + } +} diff --git a/src/OrchardCore.Themes/TheTheme/Startup.cs b/src/OrchardCore.Themes/TheTheme/Startup.cs index a13cb7756d5..fa791be1c63 100644 --- a/src/OrchardCore.Themes/TheTheme/Startup.cs +++ b/src/OrchardCore.Themes/TheTheme/Startup.cs @@ -1,11 +1,15 @@ using Microsoft.Extensions.DependencyInjection; +using OrchardCore.Admin.Models; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; +using TheTheme.Drivers; namespace OrchardCore.Themes.TheTheme; public sealed class Startup : StartupBase { - public override void ConfigureServices(IServiceCollection serviceCollection) + public override void ConfigureServices(IServiceCollection services) { + services.AddDisplayDriver(); } }