Skip to content

Commit

Permalink
Pre-render Navbar to allow resource injection (#14747)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Nov 23, 2023
1 parent 8adccea commit aa1e1bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit aa1e1bd

Please sign in to comment.