Portal Engine
Version 3.x > Portal Engine > eval fields from parent document View modes: 
User avatar
Member
Member
d.goss-galleriesfashions.co - 7/14/2009 5:08:18 PM
   
eval fields from parent document
my heirarchy of content is looking like this:

page >> product >> image file

i am making a datalist on the page which will show the image files, but I want them to be shown with fields from their parent document (product).

is there a way on a transformation you can eval fields from the parent of the current document? even if it's a different document type?

User avatar
Kentico Developer
Kentico Developer
kentico_zbysekn - 7/21/2009 11:30:58 AM
   
RE:eval fields from parent document
Hi, you can definitely create your custom function which will obtain data for you from parent document. You can find more about creating custom transformation functions in our developer's guide(Custom functions). You should pass NodeId of the image file to this function and in it's body, you should obtain image document using our API(Select document), then you should use its parentId property and again using our API select parent node and finally you can process its values.
Best Regards,
Zbysek Nemec.

User avatar
Member
Member
d.goss-galleriesfashions.co - 7/21/2009 7:58:06 PM
   
RE:eval fields from parent document
Thanks, I will try this out and let you know if it works.

User avatar
Member
Member
d.goss-galleriesfashions.co - 10/13/2009 8:45:14 AM
   
RE:eval fields from parent document
Hi, the function has been created and works perfectly. However, I need to do one more thing in this transformation - get the URL of the parent document to use in a link. I can't work out how to do this - is there a way of writing a GetDocumentURL or GetURL function that will do it, or can I use my new function to Eval a certain field?

User avatar
Kentico Developer
Kentico Developer
kentico_zbysekn - 10/13/2009 12:19:16 PM
   
RE:eval fields from parent document
Hi,
I think that you should write again your custom function or use previously created one and use this method
TreePathUtils.GetPermanentDocUrl(guid, nodeAlias.ToString(), CMSContext.CurrentSiteName)

and supply it with NodeGUID and NodeAlias values from parent document.
Best Regards,
Zbysek Nemec.

User avatar
Member
Member
d.goss-galleriesfashions.co - 10/14/2009 3:47:40 AM
   
RE:eval fields from parent document
Ok thanks that makes sense. However, I managed to get it working in the meantime by running my function to return the NodeAliasPath of the parent and then running GetUrl on the returned value. Fortunately I am only running one site so it's less complicated than it could be.

User avatar
Kentico Developer
Kentico Developer
kentico_zbysekn - 10/19/2009 8:10:02 AM
   
RE:eval fields from parent document
Hi,

Yes in your situation this is correct approach ;-).

Best Regards,
Zbysek Nemec.