Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions docs/en/framework/ui/mvc-razor-pages/page-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@

`IPageLayout` can be injected in any page/view to set the page header properties.

### RenderLayoutElements

The `RenderLayoutElements` property controls whether the application layout (navigation menu, toolbar, etc.) should be rendered around the page content:

```csharp
@inject IPageLayout PageLayout
@{
PageLayout.RenderLayoutElements = false; // Hide navigation and layout elements
}
```

* When set to `true` (default), the full application layout including navigation menu is rendered.
* When set to `false`, only the page content is rendered without the surrounding layout elements.
* This is useful for pages public pages, error pages, or embedded content where you want a clean layout without navigation.
* This is not `Empty` Layout, it's still the same layout with related page, but without the navigation menu, toolbar and footer. All the layout hooks are still available.

### Page Title

Page Title can be set as shown in the example below:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
public interface IPageLayout
{
ContentLayout Content { get; }

/// <summary>
/// Whether the application layout (navigation menu, toolbar, etc.) should be rendered around the page content.
/// </summary>
bool RenderLayoutElements { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Layout;

public class PageLayout : IPageLayout, IScopedDependency
{
public ContentLayout Content { get; }
public ContentLayout Content { get; } = new();

public PageLayout()
{
Content = new ContentLayout();
}
public bool RenderLayoutElements { get; set; } = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.MultiTenancy
@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.MainNavbar
Expand All @@ -19,6 +20,7 @@
@inject IStringLocalizer<AbpUiMultiTenancyResource> MultiTenancyStringLocalizer
@inject ITenantResolveResultAccessor TenantResolveResultAccessor
@inject IOptions<AbpThemingOptions> ThemingOptions
@inject IPageLayout PageLayout

@{
Layout = null;
Expand Down Expand Up @@ -58,7 +60,10 @@
<body class="abp-account-layout @rtl">
@await Component.InvokeLayoutHookAsync(LayoutHooks.Body.First, StandardLayouts.Account)

@(await Component.InvokeAsync<MainNavbarViewComponent>())
@if (PageLayout.RenderLayoutElements)
{
@(await Component.InvokeAsync<MainNavbarViewComponent>())
}

<div class="@containerClass">
<abp-row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@{
Layout = null;
var containerClass = ViewBag.FluidLayout == true ? "container-fluid" : "container"; //TODO: Better and type-safe options
var containerClass = ViewBag.FluidLayout == true || PageLayout.RenderLayoutElements == false ? "container-fluid" : "container"; //TODO: Better and type-safe options
var pageTitle = ViewBag.Title == null ? BrandingProvider.AppName : ViewBag.Title; //TODO: Discard to get from Title
Expand Down Expand Up @@ -63,7 +63,10 @@
<body class="abp-application-layout @rtl">
@await Component.InvokeLayoutHookAsync(LayoutHooks.Body.First, StandardLayouts.Application)

@(await Component.InvokeAsync<MainNavbarViewComponent>())
@if (PageLayout.RenderLayoutElements)
{
@(await Component.InvokeAsync<MainNavbarViewComponent>())
}

<div class="@containerClass">
@(await Component.InvokeAsync<PageAlertsViewComponent>())
Expand Down