diff --git a/15/umbraco-cms/fundamentals/code/umbraco-services.md b/15/umbraco-cms/fundamentals/code/umbraco-services.md index a50739a065d..9c2535c8b88 100644 --- a/15/umbraco-cms/fundamentals/code/umbraco-services.md +++ b/15/umbraco-cms/fundamentals/code/umbraco-services.md @@ -206,7 +206,7 @@ public class CustomNewsArticleService: ICustomNewsArticleService using (var contextReference = _contextFactory.EnsureUmbracoContext()) { IPublishedContentCache contentCache = contextReference.UmbracoContext.Content; - IPublishedContent newsSection = contentCache.GetAtRoot().FirstOrDefault().Children.FirstOrDefault(f => f.ContentType.Alias == "newsSection"); + IPublishedContent newsSection = contentCache.GetAtRoot().FirstOrDefault().Children().FirstOrDefault(f => f.ContentType.Alias == "newsSection"); if (newsSection == null) { _logger.LogDebug("News Section Not Found"); diff --git a/15/umbraco-cms/fundamentals/design/templates/basic-razor-syntax.md b/15/umbraco-cms/fundamentals/design/templates/basic-razor-syntax.md index aea1d896779..0d886804f75 100644 --- a/15/umbraco-cms/fundamentals/design/templates/basic-razor-syntax.md +++ b/15/umbraco-cms/fundamentals/design/templates/basic-razor-syntax.md @@ -40,7 +40,7 @@ Commenting your code is important, use comments to explain what the code does. ` @* Here we check if the name is equal to foobar *@ @if (Model.Name == "foobar") { - @foreach (var child in Model.Children) + @foreach (var child in Model.Children()) { @* here we write stuff for each child page *@

write stuff

@@ -73,7 +73,7 @@ else A foreach loop goes through a collection of items, typically a collection of pages and performs an action for each item ```csharp -@foreach (var item in Model.Children) +@foreach (var item in Model.Children()) {

The item name is: @Item.Name

} diff --git a/15/umbraco-cms/reference/querying/ipublishedcontent/README.md b/15/umbraco-cms/reference/querying/ipublishedcontent/README.md index c488ea8e6c1..ff3f89581fe 100644 --- a/15/umbraco-cms/reference/querying/ipublishedcontent/README.md +++ b/15/umbraco-cms/reference/querying/ipublishedcontent/README.md @@ -9,7 +9,7 @@ To access the current page in your templates, copy-paste the below Razor code. ```csharp @{ var pageName = Model.Name; - var childPages = Model.Children; + var childPages = Model.Children(); }

@pageName

diff --git a/15/umbraco-cms/reference/querying/umbracohelper.md b/15/umbraco-cms/reference/querying/umbracohelper.md index c9dd36bce2d..877c126f8cc 100644 --- a/15/umbraco-cms/reference/querying/umbracohelper.md +++ b/15/umbraco-cms/reference/querying/umbracohelper.md @@ -71,7 +71,7 @@ Given a node ID, returns a `IPublishedContent`

@pageFromGui.Value("propertyAlias")

-@foreach (var child in pageFromGui.Children) +@foreach (var child in pageFromGui.Children()) { @child.Name } @@ -83,7 +83,7 @@ Returns a collection of `IPublishedContent` objects from the Content tree. ```csharp @* Get the children of the first content item found in the root *@ -@foreach (var child in Umbraco.ContentAtRoot().First().Children) +@foreach (var child in Umbraco.ContentAtRoot().First().Children()) { @child.Name } diff --git a/15/umbraco-cms/reference/routing/custom-routes.md b/15/umbraco-cms/reference/routing/custom-routes.md index c5c992142ec..22e717586d2 100644 --- a/15/umbraco-cms/reference/routing/custom-routes.md +++ b/15/umbraco-cms/reference/routing/custom-routes.md @@ -94,7 +94,7 @@ public IActionResult Index() } ``` -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`. +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()`. Next we have our Product method: @@ -195,7 +195,7 @@ public IPublishedContent FindContent(ActionExecutingContext actionExecutingConte if (actionExecutingContext.ActionArguments.TryGetValue("id", out var sku)) { return productRoot - .Children + .Children() .FirstOrDefault(c => c.Value(_publishedValueFallback, "sku") == sku.ToString()); } else @@ -472,7 +472,7 @@ public class ShopControllerComposer : IComposer if (actionExecutingContext.ActionArguments.TryGetValue("id", out var sku)) { return productRoot - .Children + .Children() .FirstOrDefault(c => c.Value(publishedValueFallback, "sku") == sku.ToString()); } else diff --git a/15/umbraco-cms/reference/templating/mvc/querying.md b/15/umbraco-cms/reference/templating/mvc/querying.md index 6c25b1343d4..5f4f8538747 100644 --- a/15/umbraco-cms/reference/templating/mvc/querying.md +++ b/15/umbraco-cms/reference/templating/mvc/querying.md @@ -86,13 +86,13 @@ With the `IPublishedContent` model we support strongly typed LINQ queries out of #### Where children are visible ```csharp -@Model.Children.Where(x => x.IsVisible()) +@Model.Children().Where(x => x.IsVisible()) ``` #### Traverse for sitemap ```csharp -var items = @Model.Children.Where(x => x.IsVisible() && x.Level <= 4) +var items = @Model.Children().Where(x => x.IsVisible() && x.Level <= 4) ``` {% hint style="info" %} 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. #### Content sub menu ```csharp -@Model.AncestorOrSelf(1).Children.Where(x => x.DocumentTypeAlias == "DatatypesFolder").First().Children +@Model.AncestorOrSelf(1).Children().Where(x => x.DocumentTypeAlias == "DatatypesFolder").First().Children() ``` #### Complex query diff --git a/15/umbraco-cms/tutorials/creating-an-xml-site-map.md b/15/umbraco-cms/tutorials/creating-an-xml-site-map.md index 71882338200..39d80a39daa 100644 --- a/15/umbraco-cms/tutorials/creating-an-xml-site-map.md +++ b/15/umbraco-cms/tutorials/creating-an-xml-site-map.md @@ -190,10 +190,10 @@ We will add a `RenderSiteMapUrlEntriesForChildren` helper which accepts a 'Paren ```csharp void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage) { - foreach (var page in parentPage.Children) + foreach (var page in parentPage.Children()) { RenderSiteMapUrlEntry(page); - if (page.Children.Any()){ + if (page.Children().Any()){ RenderSiteMapUrlEntriesForChildren(page); } } @@ -231,11 +231,11 @@ We added a **HideFromXmlSitemap** checkbox to all Document Types via our `XmlSit void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage) { // Filter the query based on the hideFromXmlSiteMap value - foreach (var page in parentPage.Children.Where(x =>!x.Value("hideFromXmlSiteMap"))) + foreach (var page in parentPage.Children().Where(x =>!x.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntry(page); // Filter the query based on the hideFromXmlSiteMap value - if (page.Children.Any(x =>!x.Value("hideFromXmlSiteMap"))){ + if (page.Children().Any(x =>!x.Value("hideFromXmlSiteMap"))){ RenderSiteMapUrlEntriesForChildren(page); } } @@ -261,11 +261,11 @@ To further control which and how many pages are shown in the sitemap you can fil ```csharp void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage) { - foreach (var page in parentPage.Children.Where(f=>!f.Value("hideFromXmlSiteMap"))) + foreach (var page in parentPage.Children().Where(f=>!f.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntry(page); // Filter the query based on the maxSiteMapDepth value - if (page.Level < maxSiteMapDepth && page.Children.Any(f=>!f.Value("hideFromXmlSiteMap"))){ + if (page.Level < maxSiteMapDepth && page.Children().Any(f=>!f.Value("hideFromXmlSiteMap"))){ RenderSiteMapUrlEntriesForChildren(page); } } @@ -294,10 +294,10 @@ Finally, we need the helper to check the **Excluded Document Types** list on the void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage) { // Filter the query based on the excludedDocumentTypes value - foreach (var page in parentPage.Children.Where(f => !excludedDocumentTypes.Contains(f.ContentType.Alias) && !f.Value("hideFromXmlSiteMap"))) + foreach (var page in parentPage.Children().Where(f => !excludedDocumentTypes.Contains(f.ContentType.Alias) && !f.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntry(page); - if (page.Level < maxSiteMapDepth && page.Children.Any(f => !f.Value("hideFromXmlSiteMap"))) + if (page.Level < maxSiteMapDepth && page.Children().Any(f => !f.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntriesForChildren(page); } @@ -369,11 +369,11 @@ It contains an entry for each page that is void RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage) { // Filter the query based on the excludedDocumentTypes and hideFromXmlSiteMap values - foreach (var page in parentPage.Children.Where(x => !excludedDocumentTypes.Contains(x.ContentType.Alias) && !x.Value("hideFromXmlSiteMap"))) + foreach (var page in parentPage.Children().Where(x => !excludedDocumentTypes.Contains(x.ContentType.Alias) && !x.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntry(page); // Filter the query based on the maxSiteMapDepth and hideFromXmlSiteMap values - if (page.Level < maxSiteMapDepth && page.Children.Any(x => !x.Value("hideFromXmlSiteMap"))) + if (page.Level < maxSiteMapDepth && page.Children().Any(x => !x.Value("hideFromXmlSiteMap"))) { RenderSiteMapUrlEntriesForChildren(page); }