-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show ThemeToggler on supported themes only (#17243)
- Loading branch information
1 parent
a3b6f9e
commit cebac22
Showing
5 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/OrchardCore.Themes/TheTheme/Drivers/ToggleThemeNavbarDisplayDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Navbar> | ||
{ | ||
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Navbar, ToggleThemeNavbarDisplayDriver>(); | ||
} | ||
} |