How to access parent of iterated item in repeater

Jared Gotte asked on August 19, 2015 18:42

I have a Repeater on a Portal page iterating through custom Page Types. In my transformation, I want a macro to return each item's Parent's NodeOrder. I've tried {% Parent.NodeOrder %} but it apparently resolves to {% CurrentDocument.Parent.NodeOrder %} which is not what I want. Is there a way to accomplish this without having to write a custom function in App_Code?

EDIT: Basically, how do I grab the parent's NodeOrder from the child's transformation?

Thanks!

Recent Answers


Brenden Kehren answered on August 19, 2015 19:05

Use a hierarchical viewer or my personal favorite, universal viewer. It will allow you access to the parent object with fields and such without issue.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on August 19, 2015 20:04 (last edited on December 10, 2019 02:30)

Jared,

{% CurrentDocument.Parent.NodeOrder |(identity)GlobalAdministrator%} is definitely not what your looking for. CurrentDocument will return the document repeater placed on.

0 votesVote for this answer Mark as a Correct answer

Jared Gotte answered on August 19, 2015 21:31

@Brenden, could you provide an example of how to access the parent object? The document you linked and the examples on the Corporate Site do not help out. Thanks.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 20, 2015 05:12

Maybe you should state what you plan to use the NodeOrder for, then I could provide an example.

0 votesVote for this answer Mark as a Correct answer

Jared Gotte answered on August 20, 2015 16:08 (last edited on August 20, 2015 16:14)

I have 5 parents in the content tree with 5-20 children each. Parents are of CMS.MenuItem Page Type and children are of custom.Page. I have 5 Repeaters on the grandparent generating a list of names of the children. Instead of having 5 different lists (5 Repeaters), I want to make one giant list where the children are differentiated by their parent (like by the NodeOrder of the parent, for example). Essentially, I want to replicate the behavior of 5 Repeaters using just 1 Repeater so that another parent with children can be added later without having to add another Repeater. I don't want to spend the time on a too custom of a solution because there's a cost-to-benefit ratio I'm working with here. That is, the chances of another parent with children being added later is slim and adding another Repeater to compensate would be quick and easy.

I tried using a Viewer but it seems like I'm running into the same problem. Although it allows me to use hierarchical transformations, the Item transformation is just another transformation where I need to figure out how to access the parent object of each iterated item.

If I could access the parent object of each iterated item within a Repeater transformation (which I thought was possible), then I could just continue using a Repeater to accomplish my goal.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 24, 2015 23:19

What you're explaining is a hierarchy and a hierarchy or universal viewer would be your best bet. NodeOrder does not differentiate anything by a parent. Each record has a parent node ID associated with it. Look at the bottom of the www.kentico.com site. You'll see there are 3 columns with what appear to be 5 parents in them. Under each of those parents are the children. There is no need to use 5 repeaters or nest repeaters. This is specifically what a hierarchy or universal viewer are designed for, loading hierarchical data.

When you set up your transformations, you define them by page type and levels. You can also set a transformation at the top level and have it inherit through the rest of the levels. OR you can have each level be different.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.