Skip to content

Commit 97b7a22

Browse files
committed
Updating .Children and .Parent property references on IPublishedContent to the respective extension methods
1 parent 651858e commit 97b7a22

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

15/umbraco-cms/fundamentals/code/umbraco-services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public class CustomNewsArticleService: ICustomNewsArticleService
206206
using (var contextReference = _contextFactory.EnsureUmbracoContext())
207207
{
208208
IPublishedContentCache contentCache = contextReference.UmbracoContext.Content;
209-
IPublishedContent newsSection = contentCache.GetAtRoot().FirstOrDefault().Children.FirstOrDefault(f => f.ContentType.Alias == "newsSection");
209+
IPublishedContent newsSection = contentCache.GetAtRoot().FirstOrDefault().Children().FirstOrDefault(f => f.ContentType.Alias == "newsSection");
210210
if (newsSection == null)
211211
{
212212
_logger.LogDebug("News Section Not Found");

15/umbraco-cms/fundamentals/design/templates/basic-razor-syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Commenting your code is important, use comments to explain what the code does. `
4040
@* Here we check if the name is equal to foobar *@
4141
@if (Model.Name == "foobar")
4242
{
43-
@foreach (var child in Model.Children)
43+
@foreach (var child in Model.Children())
4444
{
4545
@* here we write stuff for each child page *@
4646
<p>write stuff</p>
@@ -73,7 +73,7 @@ else
7373
A foreach loop goes through a collection of items, typically a collection of pages and performs an action for each item
7474

7575
```csharp
76-
@foreach (var item in Model.Children)
76+
@foreach (var item in Model.Children())
7777
{
7878
<p>The item name is: @Item.Name</p>
7979
}

15/umbraco-cms/reference/querying/ipublishedcontent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To access the current page in your templates, copy-paste the below Razor code.
99
```csharp
1010
@{
1111
var pageName = Model.Name;
12-
var childPages = Model.Children;
12+
var childPages = Model.Children();
1313
}
1414

1515
<h1>@pageName</h1>

15/umbraco-cms/reference/querying/umbracohelper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Given a node ID, returns a `IPublishedContent`
7171

7272
<h3>@pageFromGui.Value("propertyAlias")</h3>
7373

74-
@foreach (var child in pageFromGui.Children)
74+
@foreach (var child in pageFromGui.Children())
7575
{
7676
<a href="@child.Url()">@child.Name</a>
7777
}
@@ -83,7 +83,7 @@ Returns a collection of `IPublishedContent` objects from the Content tree.
8383

8484
```csharp
8585
@* Get the children of the first content item found in the root *@
86-
@foreach (var child in Umbraco.ContentAtRoot().First().Children)
86+
@foreach (var child in Umbraco.ContentAtRoot().First().Children())
8787
{
8888
<a href="@child.Url()">@child.Name</a>
8989
}

15/umbraco-cms/reference/routing/custom-routes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public IActionResult Index()
9494
}
9595
```
9696

97-
With this method we return the view with the content found by the `FindContent` method. This can then be used to list all the children in the view with `Model.Children`.
97+
With this method we return the view with the content found by the `FindContent` method. This can then be used to list all the children in the view with `Model.Children()`.
9898

9999
Next we have our Product method:
100100

@@ -195,7 +195,7 @@ public IPublishedContent FindContent(ActionExecutingContext actionExecutingConte
195195
if (actionExecutingContext.ActionArguments.TryGetValue("id", out var sku))
196196
{
197197
return productRoot
198-
.Children
198+
.Children()
199199
.FirstOrDefault(c => c.Value<string>(_publishedValueFallback, "sku") == sku.ToString());
200200
}
201201
else
@@ -472,7 +472,7 @@ public class ShopControllerComposer : IComposer
472472
if (actionExecutingContext.ActionArguments.TryGetValue("id", out var sku))
473473
{
474474
return productRoot
475-
.Children
475+
.Children()
476476
.FirstOrDefault(c => c.Value<string>(publishedValueFallback, "sku") == sku.ToString());
477477
}
478478
else

15/umbraco-cms/reference/templating/mvc/querying.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ With the `IPublishedContent` model we support strongly typed LINQ queries out of
8686
#### Where children are visible
8787

8888
```csharp
89-
@Model.Children.Where(x => x.IsVisible())
89+
@Model.Children().Where(x => x.IsVisible())
9090
```
9191

9292
#### Traverse for sitemap
9393

9494
```csharp
95-
var items = @Model.Children.Where(x => x.IsVisible() && x.Level <= 4)
95+
var items = @Model.Children().Where(x => x.IsVisible() && x.Level <= 4)
9696
```
9797
{% hint style="info" %}
9898
The two examples below have not been verified for Umbraco 9 and 10 yet.
@@ -103,7 +103,7 @@ therefore they might not work on the latest versions of Umbraco.
103103
#### Content sub menu
104104

105105
```csharp
106-
@Model.AncestorOrSelf(1).Children.Where(x => x.DocumentTypeAlias == "DatatypesFolder").First().Children
106+
@Model.AncestorOrSelf(1).Children().Where(x => x.DocumentTypeAlias == "DatatypesFolder").First().Children()
107107
```
108108

109109
#### Complex query

15/umbraco-cms/tutorials/creating-an-xml-site-map.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ We will add a `RenderSiteMapUrlEntriesForChildren` helper which accepts a 'Paren
190190
```csharp
191191
void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage)
192192
{
193-
foreach (var page in parentPage.Children)
193+
foreach (var page in parentPage.Children())
194194
{
195195
RenderSiteMapUrlEntry(page);
196-
if (page.Children.Any()){
196+
if (page.Children().Any()){
197197
RenderSiteMapUrlEntriesForChildren(page);
198198
}
199199
}
@@ -231,11 +231,11 @@ We added a **HideFromXmlSitemap** checkbox to all Document Types via our `XmlSit
231231
void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage)
232232
{
233233
// Filter the query based on the hideFromXmlSiteMap value
234-
foreach (var page in parentPage.Children.Where(x =>!x.Value<bool>("hideFromXmlSiteMap")))
234+
foreach (var page in parentPage.Children().Where(x =>!x.Value<bool>("hideFromXmlSiteMap")))
235235
{
236236
RenderSiteMapUrlEntry(page);
237237
// Filter the query based on the hideFromXmlSiteMap value
238-
if (page.Children.Any(x =>!x.Value<bool>("hideFromXmlSiteMap"))){
238+
if (page.Children().Any(x =>!x.Value<bool>("hideFromXmlSiteMap"))){
239239
RenderSiteMapUrlEntriesForChildren(page);
240240
}
241241
}
@@ -261,11 +261,11 @@ To further control which and how many pages are shown in the sitemap you can fil
261261
```csharp
262262
void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage)
263263
{
264-
foreach (var page in parentPage.Children.Where(f=>!f.Value<bool>("hideFromXmlSiteMap")))
264+
foreach (var page in parentPage.Children().Where(f=>!f.Value<bool>("hideFromXmlSiteMap")))
265265
{
266266
RenderSiteMapUrlEntry(page);
267267
// Filter the query based on the maxSiteMapDepth value
268-
if (page.Level < maxSiteMapDepth && page.Children.Any(f=>!f.Value<bool>("hideFromXmlSiteMap"))){
268+
if (page.Level < maxSiteMapDepth && page.Children().Any(f=>!f.Value<bool>("hideFromXmlSiteMap"))){
269269
RenderSiteMapUrlEntriesForChildren(page);
270270
}
271271
}
@@ -294,10 +294,10 @@ Finally, we need the helper to check the **Excluded Document Types** list on the
294294
void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage)
295295
{
296296
// Filter the query based on the excludedDocumentTypes value
297-
foreach (var page in parentPage.Children.Where(f => !excludedDocumentTypes.Contains(f.ContentType.Alias) && !f.Value<bool>("hideFromXmlSiteMap")))
297+
foreach (var page in parentPage.Children().Where(f => !excludedDocumentTypes.Contains(f.ContentType.Alias) && !f.Value<bool>("hideFromXmlSiteMap")))
298298
{
299299
RenderSiteMapUrlEntry(page);
300-
if (page.Level < maxSiteMapDepth && page.Children.Any(f => !f.Value<bool>("hideFromXmlSiteMap")))
300+
if (page.Level < maxSiteMapDepth && page.Children().Any(f => !f.Value<bool>("hideFromXmlSiteMap")))
301301
{
302302
RenderSiteMapUrlEntriesForChildren(page);
303303
}
@@ -369,11 +369,11 @@ It contains an entry for each page that is
369369
void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage)
370370
{
371371
// Filter the query based on the excludedDocumentTypes and hideFromXmlSiteMap values
372-
foreach (var page in parentPage.Children.Where(x => !excludedDocumentTypes.Contains(x.ContentType.Alias) && !x.Value<bool>("hideFromXmlSiteMap")))
372+
foreach (var page in parentPage.Children().Where(x => !excludedDocumentTypes.Contains(x.ContentType.Alias) && !x.Value<bool>("hideFromXmlSiteMap")))
373373
{
374374
RenderSiteMapUrlEntry(page);
375375
// Filter the query based on the maxSiteMapDepth and hideFromXmlSiteMap values
376-
if (page.Level < maxSiteMapDepth && page.Children.Any(x => !x.Value<bool>("hideFromXmlSiteMap")))
376+
if (page.Level < maxSiteMapDepth && page.Children().Any(x => !x.Value<bool>("hideFromXmlSiteMap")))
377377
{
378378
RenderSiteMapUrlEntriesForChildren(page);
379379
}

0 commit comments

Comments
 (0)