Skip to content

Instantly share code, notes, and snippets.

@sitefinitySDK
Created July 28, 2020 15:51
SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://www.progress.com/documentation/sitefinity-cms/for-developers-retrieve-page-url
using System;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Pages
{
public partial class PagesSnippets
{
private string GetUrlByPageNodeIdAlternative(Guid pageNodeId, string targetCulture, bool resolveAsAbsolutUrl)
{
var siteMap = SiteMapBase.GetCurrentProvider();
// Get the siteMapNode
var siteMapNode = siteMap.FindSiteMapNodeFromKey(pageNodeId.ToString()) as PageSiteNode;
var culture = SystemManager.CurrentContext.AppSettings.GetCultureByName(targetCulture);
var url = String.Empty;
if (siteMapNode != null)
{
// Get the URL of the siteMapNode
url = siteMapNode.GetUrl(culture, false);
if (resolveAsAbsolutUrl)
{
// Get the absolute URL of the pageNode
url = UrlPath.ResolveUrl(url, true, true);
}
}
return url;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment