Craig100
08/08/2023, 11:44 AMvoid RenderSiteMapUrlEntry(IPublishedContent node)
{
var changeFreq = node.Value("searchEngineChangeFrequency", fallback: Fallback.To(Fallback.Ancestors, Fallback.DefaultValue), defaultValue: "monthly");
// with the relative priority, this is a per page setting only, so we're not using recursion, so we won't set Fallback.ToAncestors here and we'll default to 0.5 if no value is set
decimal priority = 0.5m;
if (node.HasValue("searchEngineRelativePriority")) {
string priorityConverted = node.Value<decimal>("searchEngineRelativePriority").ToString(CultureInfo.InvariantCulture);
priority = decimal.Parse(priorityConverted, CultureInfo.InvariantCulture);
}
<url>
<loc>@node.Url(mode: UrlMode.Absolute)</loc>
<lastmod>@(string.Format("{0:s}+00:00", node.UpdateDate))</lastmod>
<changefreq>@changeFreq</changefreq>
<priority>@priority</priority> // Shows 0.5 here but 0,5 in the browser!
</url>
}
I have changed the fallback priority to something other than 0.5 and it all remains as it should, so I know the "if" statement is working.
I also tried setting the priority not to vary by culture in the docType composition, but it still changes with language. I think it should vary by language anyway so that editors can set it appropriately for the market.
Does anyone have any suggestions?
Thanks.Maarten
08/08/2023, 12:53 PM@priority
which means that it will do the default ToString that is configured on the decimal. Have you tried using @priority.ToString("F",CultureInfo.InvariantCulture)
?Craig100
08/08/2023, 12:56 PMif (node.HasValue("searchEngineRelativePriority")) {
string priorityConverted = node.Value<decimal>("searchEngineRelativePriority").ToString(CultureInfo.InvariantCulture);
**priority** = decimal.Parse(priorityConverted, CultureInfo.InvariantCulture);
}
Craig100
08/08/2023, 12:57 PMMaarten
08/08/2023, 12:58 PMCraig100
08/08/2023, 12:59 PM