Rendering document type "B" after rendering n elements of document type "A" inside repeater

Chetan Sharma asked on May 19, 2014 04:12

Hello All,

I have this requirement. I have few products on my website which are of document type "A" and a promotional campaigns of document type "B".

I want to render document type "B" after processing 4 documents of doocument type "A"

Like this

Product Product Product Product

=====Promotional Message=====

Product Product Product

Is it possible to achieve something like this using repeaters?

Any ideas?

Regards, Chetan

Recent Answers


Brenden Kehren answered on May 19, 2014 07:12

Use a nested repeater within your product (doc type b) transformation. You can check if by using MOD ( % ) to see if the DataItemIndex is the 4th item and then databind the nested repeater. If you Google "nested repeater kentico" you should find some good examples.

<script runat="server">    
  protected override void OnInit(EventArgs e)
  {
    base.OnInit(e);
    if (DataItemIndex % 4 == 0)
    {
        nestedRepeater.WhereCondition = "ProdCategory = " + Eval("CatID"); // set if needed 
        nestedRepeater.ReloadData(true);
    }      
  }
</script>
0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 20, 2014 00:10

Thanks Brenden for the reply, lot of people on various forums are suggesting using Hierarchical Transformation instead of Nested repeater because of its inherent better performance.

What do you think about it? Any idea how it can be accomplished using hierarchical viewer?

Best Regards, Chetan

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 20, 2014 02:39

Can't get it working. Below is my code that I added inside the transformation of the Outer repeater. I also set the property Nested Controls ID to nestedRPT. I get only this text "Nobody" which is the value for "ZeroRowsText". Also tried various combinations for path also like "/%", "/Cattle/%" and others.

<cms:CMSRepeater ID="nestedRPT" DelayedLoading="true" DataBindByDefault="false" EnableViewState="false" runat="server" Path="/Cattle/Products-Offer/" TransformationName="pm.ShowProductOffer.productoffer" ClassNames="pm.ShowProductOffer" HideControlForZeroRows="false" ZeroRowsText="Nobody" />

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 20, 2014 06:13

If you're data is in a hierarchical format then yes using the hierarchical viewer or universal viewer will work well.

0 votesVote for this answer Mark as a Correct answer

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