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
Hey, i have created a sitemap with help from: https://our.umbraco.com/documentation/Tutorials/Creating-an-XML-Site-Map/
I ended up with this:
How can i only show the urls that returns response code 200 ?
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{Layout = null;
string blacklistedDocumentTypeList = Model.Content.GetPropertyValue<string>("blacklistedDocumentTypes"); string[] blackListedDocumentTypes = (!String.IsNullOrEmpty(blacklistedDocumentTypeList)) ? blacklistedDocumentTypeList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) : new string[] { }; int maxSiteMapDepth = Model.Content.HasValue("maxSiteMapDepth") ? Model.Content.GetPropertyValue<int>("maxSiteMapDepth") : int.MaxValue; IPublishedContent siteHomePage = Model.Content.Parent;
}
@{ @helper RenderSiteMapUrlEntry(IPublishedContent node) { // with the relative priority, this is a per page setting, so we're not passing true var priority = node.GetPropertyValue
if (String.IsNullOrEmpty(priority)) { priority = "0.4"; } <url> <loc>@EnsureUrlStartsWithDomain(node.UrlWithDomain())</loc> <lastmod>@(string.Format("{0:s}+00:00", node.UpdateDate))</lastmod> <priority>@priority.Replace(",", ".")</priority> </url> } @helper RenderSiteMapUrlEntriesForChildren(IPublishedContent parentPage, int maxSiteMapDepth, string[] documentTypeBlacklist) { foreach (var page in parentPage.Children.Where(f => !documentTypeBlacklist.Contains(f.DocumentTypeAlias) && !f.GetPropertyValue<bool>("hideFromSiteMap"))) { @RenderSiteMapUrlEntry(page) if (page.Level < maxSiteMapDepth && page.Children.Any(f => !documentTypeBlacklist.Contains(f.DocumentTypeAlias) && !f.GetPropertyValue<bool>("hideFromSiteMap"))) { @RenderSiteMapUrlEntriesForChildren(page, maxSiteMapDepth, documentTypeBlacklist) } } }
@functions { private static string EnsureUrlStartsWithDomain(string url) { if (url.StartsWith("http")) { return url; } else { // whatever makes sense for your site here... var domainPrefix = string.Format("https://{0}/", HttpContext.Current.Request.ServerVariables["HTTP_HOST"]); return domainPrefix + url; } } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Sitemap only show when url is response code 200
Hey, i have created a sitemap with help from: https://our.umbraco.com/documentation/Tutorials/Creating-an-XML-Site-Map/
I ended up with this:
How can i only show the urls that returns response code 200 ?
@{Layout = null;
}
@{ @helper RenderSiteMapUrlEntry(IPublishedContent node) { // with the relative priority, this is a per page setting, so we're not passing true var priority = node.GetPropertyValue
}
@functions { private static string EnsureUrlStartsWithDomain(string url) { if (url.StartsWith("http")) { return url; } else { // whatever makes sense for your site here... var domainPrefix = string.Format("https://{0}/", HttpContext.Current.Request.ServerVariables["HTTP_HOST"]); return domainPrefix + url; } } }
is working on a reply...