Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Get parrent url information from inside kentico transformations View modes: 
User avatar
Member
Member
wukimus-hotmail - 9/11/2013 12:04:03 PM
   
Get parrent url information from inside kentico transformations
Good day All,

I have a problem lets say my file structure is as such:

Gallery1
-image1
-image2
Gallery2
-image1
-image2

And I have a repeater web part that using a transformation. I want to be able to put in the anchor tag the parent url of these images <a href="<# parentlaocation %>"><img src="<# GetFileUrl("Image")%>" class="ab"/></a>

therefor if i am here Gallery2>image1 the href would render the url of Gallery2.

Thanks for your usual help.





User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 9/11/2013 1:56:45 PM
   
RE:Get parrent url information from inside kentico transformations
As of right now I believe there is only a method available that uses the NodeGuid. The result set should return the NodeParentID in which you could create a simple function in code behind to get the URL for the parent node or the NodeAilasPath based on the NodeParentID. Shouldn't be much code at all. You could even put it in your Transformation. Here is some code that should work
<script runat="server">
protected string GetParentUrl(int parentNodeId)
{
string returnurl = "#";
CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider();
CMS.DocumentEngine.TreeNode tn = tree.SelectSingleNode(parentNodeId);
if (tn != null)
{
returnurl = tn.NodeAliasPath;
}
return returnurl;
}
</script>
Then in your code you provided simply do
href="<%# GetParentUrl(EvalInteger("NodeParentID")) %>"

User avatar
Member
Member
wukimus-hotmail - 9/11/2013 2:18:51 PM
   
RE:Get parrent url information from inside kentico transformations
Works like a charms, all smiles

Thanks again