diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/NavbarUserMenu.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/NavbarUserMenu.cshtml index c312352bf84..baeae2fd23c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/NavbarUserMenu.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/NavbarUserMenu.cshtml @@ -5,5 +5,5 @@ @inject IUpdateModelAccessor UpdateModelAccessor diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/TwoFactorAuthentication/LoginWithTwoFactorAuthentication.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/TwoFactorAuthentication/LoginWithTwoFactorAuthentication.cshtml index c8341dd7a58..f81d1c2cca5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/TwoFactorAuthentication/LoginWithTwoFactorAuthentication.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/TwoFactorAuthentication/LoginWithTwoFactorAuthentication.cshtml @@ -28,7 +28,7 @@ @if (!string.IsNullOrEmpty(Model.CurrentProvider)) { - var shape = await DisplayManager.BuildEditorAsync(new TwoFactorMethod(), UpdateModelAccessor.ModelUpdater, false, Model.CurrentProvider, string.Empty); + var shape = await DisplayManager.BuildEditorAsync(UpdateModelAccessor.ModelUpdater, false, Model.CurrentProvider); @await DisplayAsync(shape) } diff --git a/src/OrchardCore.Themes/TheAdmin/Views/Layout.cshtml b/src/OrchardCore.Themes/TheAdmin/Views/Layout.cshtml index 22cf70aca23..80381739a72 100644 --- a/src/OrchardCore.Themes/TheAdmin/Views/Layout.cshtml +++ b/src/OrchardCore.Themes/TheAdmin/Views/Layout.cshtml @@ -60,7 +60,7 @@ } - @await DisplayAsync(await DisplayManager.BuildDisplayAsync(new Navbar(), UpdateModelAccessor.ModelUpdater, "DetailAdmin")) + @await DisplayAsync(await DisplayManager.BuildDisplayAsync(UpdateModelAccessor.ModelUpdater, "DetailAdmin")) diff --git a/src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml b/src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml index 956afd37c5b..4acac82ddf6 100644 --- a/src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml +++ b/src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml @@ -49,7 +49,7 @@ diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Extensions/DisplayManagerExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Extensions/DisplayManagerExtensions.cs new file mode 100644 index 00000000000..5b4199e0708 --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Extensions/DisplayManagerExtensions.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using OrchardCore.DisplayManagement.ModelBinding; + +namespace OrchardCore.DisplayManagement; + +public static class DisplayManagerExtensions +{ + public static Task BuildDisplayAsync(this IDisplayManager displayManager, IUpdateModel updater, string displayType = "", string groupId = "") where TModel : new() + => displayManager.BuildDisplayAsync(new TModel(), updater, displayType, groupId); + + public static Task BuildEditorAsync(this IDisplayManager displayManager, IUpdateModel updater, bool isNew, string groupId = "", string htmlPrefix = "") where TModel : new() + => displayManager.BuildEditorAsync(new TModel(), updater, isNew, groupId, htmlPrefix); +} diff --git a/src/docs/releases/1.8.0.md b/src/docs/releases/1.8.0.md index 2e5eaa0fd5d..fea359a8af4 100644 --- a/src/docs/releases/1.8.0.md +++ b/src/docs/releases/1.8.0.md @@ -59,3 +59,23 @@ public class ToggleThemeNavbarDisplayDriver : DisplayDriver Additionally, the follow shapes have been removed - `ContentCulturePickerContainer` - `AdminCulturePickerContainer` + +#### `Navbar` Shape for Custom Theme + +To add the `Navbar` shape into your own front-end theme, add the following code into your layout. + +``` +@inject IDisplayManager DisplayManager +@inject IUpdateModelAccessor UpdateModelAccessor + +@await DisplayAsync(await DisplayManager.BuildDisplayAsync(UpdateModelAccessor.ModelUpdater)) +``` + +To add the `Navbar` shape into your own back-end theme, add the following code into your layout. + +``` +@inject IDisplayManager DisplayManager +@inject IUpdateModelAccessor UpdateModelAccessor + +@await DisplayAsync(await DisplayManager.BuildDisplayAsync(UpdateModelAccessor.ModelUpdater, "DetailAdmin")) +```