How to add Repeater web part inside a Hierarchical Viewer transformation?

Jump Griarte asked on June 2, 2017 03:57

Hello again,

I am trying to include a Repeater web part inside a Hierarchical Viewer Item transformation.
I have this setup where I would display 2 levels of different page types and on the bottom of each first-level item.
I will be displaying a Repeater after {^SubLevelPlaceHolder^} that gets page type data from a different source path.

- Parent1
-- Child1
-- Child2
- Repeater1
- Parent2
-- Child3
- Repeater2

I would greatly appreciate any sample codes to be used inside a transformation.
I need the default CMSRepeater, or if you could also demo how to include a custom web part that would be better.

Thanks in advance!

Recent Answers


Dawid Jachnik answered on June 2, 2017 09:11

Hello,

It's not recommended to use Repeater inside another Repeater or Hierarchical Viewer. If you can't do that with Hierarchical Viewer, maybe try to a little bit similar web part, but with custom query Universal viewer with custom query ? Or try to pin Data source to your current viewer

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on June 2, 2017 11:23 (last edited on June 2, 2017 11:23)

Jump, As Dawid suggested, try to avoid it as long as you can. Think hard about your problem if the data can structured hierarchically and supply it to HV.

If in case nothing works out please try to explain what you're trying to achiever here that why are you using a nested repeater as it hits performance.

IN case you've already decided then you can refer this article - https://docs.kentico.com/k10/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/using-nested-controls

I am afraid you'' have to use ascx controls instead of Text/XML for nested repeaters to work.

Thanks, Chetan

1 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 2, 2017 13:05

Instead of registering nested repeater, use the Applytransformation method over a document collection you want to render like:

{^SubLevelPlaceHolder^}
{%Documents[NodeAliasPath].Children.ApplyTransformation("cms.menuitem.mytransformation")%}
2 votesVote for this answer Mark as a Correct answer

Jump Griarte answered on June 3, 2017 06:13

Hi all,

I need to use a Repeater because I need to insert data from a different path, different from what is specified in Hierarchical Viewer web part.
To explain further, I have this setup where I want to iterate a path which displays an "Insurance Type" then we have "Insurance Policies" under it.

It will look like something below:

[Insurance Type 1]
   [Insurance Policy 1]    [Insurance Policy 2]
   [Insurance Policy 3]    [Insurance Policy 4]

Contact Persons for [Insurance Type 1]
   [Contact Person A Image]   [Contact Person B Image]   [Contact Person C Image]
   [Contact Person A Name]    [Contact Person B Name]    [Contact Person C Name]
   [Contact Person A Address] [Contact Person B Address] [Contact Person C Address]

[Insurance Type 2]
   [Insurance Policy 5]    [Insurance Policy 6]
   [Insurance Policy 7]

Contact Persons for [Insurance Type 2]
   [Contact Person A Image]   [Contact Person D Image]
   [Contact Person A Name]    [Contact Person D Name]
   [Contact Person A Address] [Contact Person D Address]

As you can see, we have multiple Insurance Types and under it, we have multiple Insurance Policies unique to the Insurance Type.
But not the Contact Persons. I want it to be reusable from a different path.
I am thinking it will be based on the selected "Page Relationship Name", I plan to have it as a custom field for Insurance Type.

For now, I am using the Hierarchical Viewer to display one Insurance Type at a time. Then, having the Repeater as a separate web part underneath it, just like this:

[Hierarchical Viewer for Insurance Type 1]
[Repeater for Contact Persons for Insurance Type 1]
[Hierarchical Viewer for Insurance Type 2]
[Repeater for Contact Persons for Insurance Type 2]

I was hoping it's possible to make this as one Hierarchical Viewer web part to iterate to all Insurance Types with its corresponding Contact Persons based on its custom field.

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 5, 2017 09:59

This still looks like a good example of the ApplyTransformation method:

{%Documents.Where("ClassName='cms.contact' and NodeParentID="+NodeID).ApplyTransformation("cms.menuitem.contactformation")%}

1 votesVote for this answer Mark as a Correct answer

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