Skip to content

Commit f13b3df

Browse files
committed
Update and remove existing article
1 parent 9e51f2a commit f13b3df

18 files changed

+100
-184
lines changed

14/umbraco-cms/.gitbook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ redirects:
130130
fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/label-property-configuration: reference/umbraco-flavored-markdown.md
131131
customizing/property-editors/build-a-block-editor: fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/README.md
132132
tutorials/creating-and-distributing-a-package: extending/packages/creating-a-package.md
133+
fundamentals/design/templates/named-sections: fundamentals/design/templates/README.md

14/umbraco-cms/SUMMARY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
* [Design](fundamentals/design/README.md)
104104
* [Templates](fundamentals/design/templates/README.md)
105105
* [Basic Razor Syntax](fundamentals/design/templates/basic-razor-syntax.md)
106-
* [Named Sections](fundamentals/design/templates/named-sections.md)
107106
* [Razor Cheatsheet](fundamentals/design/templates/razor-cheatsheet.md)
108107
* [Rendering Content](fundamentals/design/rendering-content.md)
109108
* [Rendering Media](fundamentals/design/rendering-media.md)

14/umbraco-cms/fundamentals/design/templates/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ The code from the Template replaces the `@RenderBody()` tag in the Master Templa
9999
</html>
100100
```
101101

102-
## Template Sections
102+
## Named Sections
103103

104104
Template Sections give you added flexibility when building your templates. Use the Template Section together with a Master Template setup, to decide where sections of content is placed.
105105

106-
If a Child Template needs to add code to the `<head>` tag a Section must be defined and then used in the Master Template. This is made possible by [Named Sections](https://www.youtube.com/watch?v=lrnJwglbGUA).
106+
If a Child Template needs to add code to the `<head>` tag a Section must be defined and then used in the Master Template. This is made possible by [Named Sections](https://www.youtube.com/watch?v=lrnJwglbGUA).
107107
108108
The following steps will guide you through defining and using a Named Section:
109109

@@ -112,23 +112,26 @@ The following steps will guide you through defining and using a Named Section:
112112
3. Choose **Define a named section**.
113113
4. Give the section a name and click **Submit**.
114114

115-
On your child page template call `@section Head {}` and then type your markup that will be pushed into the Master Template:
115+
![Define a named section by giving it a name](images/defined-named-section.png)
116+
117+
The following code will be added to your Template:
116118

117119
```csharp
118-
@section Head {
119-
<style>
120-
body {
121-
background: #ff0000;
122-
}
123-
</style>
120+
@section SectionName {
121+
124122
}
125123
```
126124

127-
```csharp
128-
@RenderSection("SectionName")
129-
```
125+
5. Add whichever code you need between the curly brackets.
126+
6. Save the changes.
127+
7. Open the Master Template.
128+
8. Choose a spot for the section, and set the cursor there.
129+
9. Select the **Sections** option.
130+
10. Choose **Render a named section**.
131+
11. Enter the name of the section you want to add.
132+
12. Click **Submit**.
130133

131-
For instance, if you want to be able to add HTML to your `<head>` tags write:
134+
For instance, if you want to be able to add HTML to your `<head>` tags, you would add the tag there:
132135

133136
```csharp
134137
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@@ -139,23 +142,26 @@ For instance, if you want to be able to add HTML to your `<head>` tags write:
139142
<html>
140143
<head>
141144
<title>Title</title>
142-
@RenderSection("Head")
145+
@RenderSection("SectionName")
143146
</head>
144147

145148
<body>
146149
</body>
147150
</html>
148151
```
149152

150-
By default, when rendering a named section, the section is not mandatory. To make the section mandatory, add `true` or enable **Section is mandatory** field in the **Sections** option.
153+
You can decide whether a section should be mandatory or not. Making a section mandatory means that any templates using the Master Template is required to have the section defined.
154+
155+
To make the section mandatory, you have two options:
156+
157+
* Check the **Section is mandatory** field when using the **Sections** dialog in the backoffice.
158+
* Add `true` to the code tag like shown in the example below.
151159

152160
```csharp
153161
@RenderSection("Head", true)
154162
```
155163

156-
![Create partial](../../../../../10/umbraco-cms/fundamentals/design/templates/images/render-named-sections-v10.png)
157-
158-
164+
![Create partial](images/render-named-section-mandatory.png)
159165

160166
## Injecting Partial Views
161167

@@ -186,9 +192,3 @@ The created partial view can now be injected into any template by using the `@Ht
186192
### Tutorials
187193

188194
* [Creating a basic website with Umbraco](../../../tutorials/creating-a-basic-website/)
189-
190-
### Umbraco Learning Base
191-
192-
{% embed url="https://www.youtube.com/playlist?ab_channel=UmbracoLearningBase&list=PLgX62vUaGZsFmzmm4iFKeL41CZ5YFw09z" %}
193-
Playlist: Templates in Umbraco
194-
{% endembed %}
Binary file not shown.
Binary file not shown.
Loading
Loading
Binary file not shown.

14/umbraco-cms/fundamentals/design/templates/named-sections.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

15/umbraco-cms/.gitbook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,4 @@ redirects:
112112
fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/label-property-configuration: reference/umbraco-flavored-markdown.md
113113
customizing/property-editors/build-a-block-editor: fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/README.md
114114
tutorials/creating-and-distributing-a-package: extending/packages/creating-a-package.md
115+
fundamentals/design/templates/named-sections: fundamentals/design/templates/README.md

0 commit comments

Comments
 (0)