Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Inserting document ID into WhereCondition of Nested Repeater View modes: 
User avatar
Member
Member
acasal-imediainc - 7/9/2012 9:41:10 AM
   
Inserting document ID into WhereCondition of Nested Repeater
I have a nested repeater being used as a left nav. On the secondary page, I want it to show only the tertiary items of the current secondary page. None of the tertiary items of other secondary items should show on this repeater. The problem I am having is that I currently have it where all the tertiary items are showing, since it can only retrieve information in the context of the first (parent) repeater.

I feel like I should be able to call the document ID of the current page and insert it into the transformation of the second (child) repeater, but again, it can only retrieve document ID and Node ID from its parent repeater item only.

Would you be able to help me find a custom function or code to help me figure out this problem? Thanks!

User avatar
Kentico Support
Kentico Support
kentico_janh - 7/10/2012 3:56:35 AM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Hello,

I am a bit lost in your description of the issue you are facing. Would it be possible to show it on some specific example (or take a screenshot of it)? Could you please also post the code of your transformation and related properties you have filled into your repeaters?

Best regards,
Jan Hermann

User avatar
Member
Member
acasal-imediainc - 7/11/2012 4:10:33 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Here are my two transformations in the repeater. The repeater is using the leftNav transformation. And the leftNav transformation is calling the "leftNav2" transformation and "repeater2" repeater

My transformation: leftNav

<li><div class="both clearfix"><a href="<%# GetDocumentUrl() %>"><%# Eval("DocumentName") %></a>
<%# IfEmpty(Eval("MenuItemFlyoutInfo"), "", "<div class='flyout'><div class='top'></div><div class='desc'>" + Eval("DocumentName") + "hi<br />" + Eval("MenuItemFlyoutInfo") + "</div></div>") %>
</div>
<ul class="leftNavCMSListMenuUL level2">
<cms:CMSRepeater
ID='repeater'
runat='server'
ClassNames='CMS.MenuItem;custom.LubeListing;custom.Lube'
TransformationName='CMS.MenuItem.leftNav2'
Path='./%'
OrderBy='NodeLevel, NodeOrder, NodeName'
WhereCondition='NodeLevel = 2'
NestedControlsID='repeater2'
/>
</ul>
</li>


My transformation: leftNav2


<li><div class="both"><a href="<%# GetDocumentUrl() %>"><%# Eval("DocumentName") %></a>
<%# IfEmpty(Eval("MenuItemFlyoutInfo"), "", "<div class='flyout'><div class='top'></div><div class='desc'>" + Eval("MenuItemFlyoutInfo") + "</div></div>") %>
</div>
<ul class="leftNavCMSListMenuUL level3">
<cms:CMSRepeater DelayedLoading="true" StopProcessing="true"
ID='repeater2'
runat='server'
ClassNames='CMS.MenuItem;custom.LubeListing;custom.Lube'
TransformationName = 'CMS.MenuItem.leftNav3'
Path='./%'
WhereCondition='NodeParentID = 779'
OrderBy='NodeLevel, NodeOrder, NodeName'
/>
</ul>
</li>


Right now, I have "NodeParentID = 779" to call any third level items that have a parent ID of 779. It works on the page that has the Node ID of 779 of course. But I want the where condition to use the Node ID of whatever page I'm on.

Thanks!

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/10/2012 3:57:03 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
You can throw a little bit of script runat=server in your template and do things you need. You may need to tweak this a bit to get it to work. I'm just showing you a hypothetical solution.

Remember than an AXCX transformation is just a user control that inherits from CMSAbstractTransformation, so you can treat is as though it is a regular user control.


<script runat="server">
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
MyNestedRepeater.WhereCondition = String.Format("DocumentID = {0}", Eval("DocumentID"));
}
</script>

User avatar
Member
Member
Accepted solutionAccepted solution
acasal-imediainc - 7/11/2012 4:14:18 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Thanks for your help. I just replied to the other person with my code.

I'm not exactly sure where you wanted me to put it, but I took a guess. I put in my fields and placed your code at the end of the leftnav2 transformation and it didn't work.


<script runat="server">
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
repeater2.WhereCondition = String.Format("NodeParentID = {0}", Eval("NodeID"));
}
</script>


Could you be more specific as to where I should put it? Thanks a lot!

Andrew

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/12/2012 3:10:52 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Sorry,
You put it anywhere in your the same transformation that contains your nested repeater.

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/12/2012 3:13:18 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
I guess you did put it where it needs to go, try changing the event that you override or subscribe to. I know that it will work, I just can't remember exactly how I did it before.

User avatar
Member
Member
acasal-imediainc - 7/18/2012 10:45:28 AM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Sorry for the late response, just got back from vacation. I checked to see what I was putting into the where condition. It seems that it still takes the NodeID of the parent repeater item, not of the current page where the repeater/menu lives. Is there a way to fix this?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/23/2012 3:42:19 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Oh, I thought you wanted it to use the NodeID of the parent repeater Item. Try using CMSContext.CurrentDocument.NodeID instead of Eval("NodeID");

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/14/2012 5:15:07 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
Hi,

in case you would like to display data from a particular level, you can play with a NodeLevel property. For example set it to 3.

A repeater has a nested control ID property, you may try to play with its configuration as well.

Finally, it is important to call in the script part:

repeaterControlId.ReloadData() method.

One more idea:

You can also play with Path expressions. For example path:

/{0}/{1}/% will display only third level items of current document.

Best regards,
Ivana Tomanickova

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/23/2012 3:44:18 PM
   
RE:Inserting document ID into WhereCondition of Nested Repeater
I like Ivana's solution. If that is what you're trying to do, her solution should work very well.