Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > How to get Friendly URL of a document selector in transformation View modes: 
User avatar
Member
Member
dantahoua-gmail - 12/19/2011 2:29:37 PM
   
How to get Friendly URL of a document selector in transformation
Hello.
I created a new document type (for a slider). In this Document Type, I have a field named "SliderLink" wich is field type :"Document Selector" , attribute :Text...
When I create a new document, I am able to choose a page on my website.
I then create a repeater in wich I use a transformation with "GetDocumentUrl("SliderLink","")"
The problem I have is that I get a URL like "getdoc/91902782-67bf-4109-8ca2-3ab338a3eb5e/default/"...
I tried several thing, but I am not able to have the friendly url to this page... (I tried resolveURL, uncheck "permanent URL"...).
Do I have to make a custom function? If yes, how to?
Thanks.

User avatar
Member
Member
dantahoua-gmail - 12/20/2011 1:05:42 PM
   
RE:How to get Friendly URL of a document selector in transformation
Finally, I had to make a custom function. I grap some code all around the Kentico website. Here is my code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CMS.GlobalHelper;
using CMS.CMSHelper;
/// <summary>
/// Retourne l'URL "amicale" d'un document
/// </summary>
public static class FriendlyURL
{
public static string ReturnFriendlyUrl(string nodeGuidParam)
{
try
{
if (nodeGuidParam != null && nodeGuidParam.Trim() != "")
{
string nodeGuidStr = ValidationHelper.GetString(nodeGuidParam, "");
Guid nodeGUID = new Guid(nodeGuidStr);
if (nodeGUID != null)
{
int nodeId = CMS.TreeEngine.TreePathUtils.GetNodeIdByNodeGUID(nodeGUID, CMS.CMSHelper.CMSContext.CurrentSiteName);

if (nodeId != null)
{
CMS.TreeEngine.TreeProvider tp = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
CMS.TreeEngine.TreeNode node = tp.SelectSingleNode(nodeId);

return CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
}
}
}
return "";
}
catch
{
return "";
}
}
}