kentico_michal
-
10/26/2010 6:55:41 AM
RE:Using document selector in transformation
Hi,
You could use standard <%# GetDocumentUrl("NodeGUIDColumn", "NodeAlias") %> method. This method returns URL, that contains GUID, so from SEO point of view is better to use different approach. I would recommend you to use following custom method in transformation. Please find more information about adding custom functions to transformation in Developer’s guide : http://devnet.kentico.com/docs/devguide/index.html?adding_custom_functions_to_transformations.htm
public static string GUIDtoURL(object inputGUID) { string txtGUID = (string) inputGUID; Guid guid = new Guid(txtGUID); if (guid != null) { int nodeid = CMS.TreeEngine.TreePathUtils.GetNodeIdByNodeGUID(guid, CMS.CMSHelper.CMSContext.CurrentSite.SiteName); CMS.TreeEngine.TreeNode node = CMS.CMSHelper.TreeHelper.SelectSingleNode(nodeid);
return CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMS.CMSHelper.CMSContext.CurrentSiteName); } return ""; }
You could use following string to execute this custom method in transformation <%# MyFunctions.GUIDtoURL(Eval("documentSelectorField")) %>
Best regards, Michal Legen
|