Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
When umbracoNaviHide is set to true on a node (say a container) but you want the sitemap to display it's children, then the script will not get the children.
This may not apply to everyone but this is what I did to the script:
@ListChildNodes(Model.AncestorOrSelf(1))@helper ListChildNodes(dynamic startNode) { Response.ContentType = "text/xml"; const int maxLevelForSiteMap = 100; foreach (var node in startNode.Children) { if (node.template > 0) { if (node.umbracoNaviHide == false && node.HasAccess && !node.IsProtected) {
Hi Anthony,
I needed this solution also so I've changed the code to support parent nodes (containers or classic pages) to work with umbracoNaviHide.
@using Umbraco.Core.Models @using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var startNode = Model.Content.AncestorOrSelf(1); } @CreateXML(startNode) @ListChildNodes(startNode) @helper ListChildNodes(IPublishedContent startNode) { Response.ContentType = "text/xml"; const int maxLevelForSiteMap = 100; foreach (var node in startNode.Children) { if (node.TemplateId > 0) { @CreateXML(node) } if (node.Level <= maxLevelForSiteMap && node.Children.Any()) { @ListChildNodes(node) } } } @helper CreateXML(IPublishedContent node) { if (node.IsVisible() && Umbraco.MemberHasAccess(node.Path) && !Umbraco.IsProtected(node.Path)) { <url> <loc>@node.UrlAbsolute()</loc> <lastmod>@($"{node.UpdateDate:s}+00:00")</lastmod> @{ var frequency = node.GetPropertyValue<string>("SearchEngineSitemapChangeFreq"); var priority = node.GetPropertyValue<string>("SearchEngineSitemapPriority"); } @if (!string.IsNullOrEmpty(frequency)) { <changefreq>@frequency</changefreq> } @if (!string.IsNullOrEmpty(priority)) { <priority>@priority</priority> } </url> } }
Cheers,
Bojan
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Razor version issue
When umbracoNaviHide is set to true on a node (say a container) but you want the sitemap to display it's children, then the script will not get the children.
This may not apply to everyone but this is what I did to the script:
Hi Anthony,
I needed this solution also so I've changed the code to support parent nodes (containers or classic pages) to work with umbracoNaviHide.
Cheers,
Bojan
is working on a reply...