Overview
On a Page Type, you can create a property for a web link to a page. This page might be part of the CMS, or it might be on a different site. How can you find out how to render it?
Process
First, you need to get the PropertyData for the property. It might not have a value, but even if it does, the value is just an internal reference to the the page, for example "/templates/MyTemplate.aspx?id=1076". Not very helpful, is it?
Here's a quick method that you can use to return a PageData if the property references a CMS page, or a string with the URL otherwise. You'll still need to check to see which one is returned, if either.
Example code
static void GetPagePropertyLink(PageData CurrentPage, string PropertyName, out PageData pTarget, out string uTarget) {
pTarget = null;
uTarget = null;
PropertyData pUrl = CurrentPage.Property[PropertyName];
if (pUrl == null) return;
if (pUrl.IsNull) return;
try
{
pTarget = EPiServer.Global.EPDataFactory.GetPage(
PageReference.ParseUrl(pUrl.ToString()), EPiServer.Security.AccessLevel.Read);
}
catch (EPiServer.Core.PageNotFoundException) { }
catch (ArgumentException) { }
if (pTarget == null) uTarget = pUrl.Value.ToString();
return;
}
Versions
Metadata