Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-render Navbar to allow resource injection #14747

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/OrchardCore.Themes/TheAdmin/Views/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
@{
var adminSettings = Site.As<AdminSettings>();

// Branding is pre-rendered to allow resource injection
// Branding and Navbar are pre-rendered to allow resource injection
var brandingHtml = await DisplayAsync(await New.AdminBranding());
var navbar = await DisplayManager.BuildDisplayAsync<Navbar>(UpdateModelAccessor.ModelUpdater, "DetailAdmin");
}
<!DOCTYPE html>
<html lang="@Orchard.CultureName()" dir="@Orchard.CultureDir()" data-bs-theme="@await ThemeTogglerService.CurrentTheme()" data-tenant="@ThemeTogglerService.CurrentTenant">
Expand Down Expand Up @@ -60,7 +61,7 @@
}
</div>
</div>
@await DisplayAsync(await DisplayManager.BuildDisplayAsync<Navbar>(UpdateModelAccessor.ModelUpdater, "DetailAdmin"))
@await DisplayAsync(navbar)
</div>
</div>
</nav>
Expand Down
4 changes: 3 additions & 1 deletion src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
@inject ThemeTogglerService ThemeTogglerService
@{
var adminSettings = Site.As<AdminSettings>();
// Navbar is pre-rendered to allow resource injection
var navbar = await DisplayManager.BuildDisplayAsync<Navbar>(UpdateModelAccessor.ModelUpdater);
}
<!DOCTYPE html>
<html lang="@Orchard.CultureName()" dir="@Orchard.CultureDir()" data-bs-theme="@await ThemeTogglerService.CurrentTheme()" data-tenant="@ThemeTogglerService.CurrentTenant">
Expand Down Expand Up @@ -49,7 +51,7 @@
<div class="collapse navbar-collapse" id="navbar">
<div class="d-flex w-100 align-items-end justify-content-end justify-content-md-between flex-column flex-md-row">
<menu alias="alias:main-menu" cache-id="main-menu" cache-fixed-duration="00:05:00" cache-tag="alias:main-menu" />
@await DisplayAsync(await DisplayManager.BuildDisplayAsync<Navbar>(UpdateModelAccessor.ModelUpdater))
@await DisplayAsync(navbar)
</div>
</div>
</div>
Expand Down