Skip to content

Commit 75ab039

Browse files
committed
Merge branch 'rel-9.2' of https://github.com/abpframework/abp into rel-9.2
2 parents 3d5d10f + 999138a commit 75ab039

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docs/en/framework/ui/blazor/layout-hooks.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ABP theming system places the page layout into the [theme](theming.md) NuGet packages. That means the final application doesn't include a layout, so you can't directly change the layout code to customize it.
44

5-
> If you create a Blazor WASM project, the `index.html` file will be included within the template. You can also customize it to your needs.
5+
> If you created your Blazor application with ABP templates, then you'll have an `App.razor` file in your project. You can customize it to your needs and even extend it with layout hooks.
66
77
You can copy the theme code into your solution. In this case, you are completely free to customize it. However, then you won't be able to get automatic updates of the theme (by upgrading the theme NuGet package).
88

@@ -101,11 +101,41 @@ See the *Layouts* section below to learn more about the layout system.
101101

102102
There are some pre-defined layout hook points. The standard hook points are:
103103

104+
* `LayoutHooks.Head.First`: Used to add a component as the first item in the HTML head tag.
105+
* `LayoutHooks.Head.Last`: Used to add a component as the last item in the HTML head tag.
104106
* `LayoutHooks.Body.First`: Used to add a component as the first item in the HTML body tag.
105107
* `LayoutHooks.Body.Last`: Used to add a component as the last item in the HTML body tag.
106108

107109
> You (or the modules you are using) can add **multiple items to the same hook point**. All of them will be added to the layout in the order they were added.
108110
111+
### Render LayoutHooks.Head in App.razor
112+
113+
In your Blazor application, there is an `App.razor` file, which acts as the entry point of your application. If you need to render layout hooks between the **head** tags, then you should manually register the layout hooks as below:
114+
115+
```csharp
116+
@using Volo.Abp.AspNetCore.Components.Web.Theming.Components.LayoutHooks;
117+
@using Volo.Abp.Ui.LayoutHooks;
118+
@using Volo.Abp.AspNetCore.Components.Web.Theming.Layout;
119+
120+
<!DOCTYPE html>
121+
<html>
122+
<head>
123+
<LayoutHook Name="@LayoutHooks.Head.First" Layout="@StandardLayouts.Application" />
124+
125+
// Your head content
126+
// ...
127+
128+
<LayoutHook Name="@LayoutHooks.Head.Last" Layout="@StandardLayouts.Application" />
129+
</head>
130+
<body>
131+
// Your body content
132+
// ...
133+
</body>
134+
</html>
135+
```
136+
137+
After registering the related layout hooks, you can define components to render in the specific place accordingly as mentioned above.
138+
109139
## Layouts
110140

111141
The layout system allows themes to define the standard named layouts and allows any page to select a proper layout for its purpose. There is one pre-defined layout:

0 commit comments

Comments
 (0)