ASPX templates
Version 7.x > ASPX templates > Repeater nested in transformation View modes: 
User avatar
Member
Member
jenf-deschutes - 12/13/2013 4:11:52 PM
   
Repeater nested in transformation
Good afternoon -

I'm using a CMSUniView and hierarchical transformations to display information from Kentico on a page. In some cases, I only want to show child items for certain document types. For example:

- Page
-- Folder
--- Article
--- Article
---- Article (NOT shown because Article is parent)
--- File
-- Folder
--- Article
--- Folder
---- Article (shown because Folder is parent)

I've tried using the CMSRepeater control inside the transformation for the 3rd level folder, with mixed results. I can't seem to get the "path" statement right. If I leave the "path" statement empty I get all the articles, regardless of their parent branch. If I put anything in the "path" statement, typically I get no data.

Seems like there should be a way to add a macro to the "path" statement, similar to

Eval('NodeAliasPath')/%

But that doesn't work either. Any thoughts on how to get this working?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/19/2013 2:11:43 AM
   
RE:Repeater nested in transformation
Hello,

What is the exact nested repeater configuration? Have you tried using the DelayedLoading="true" property so it has time to load its settings? Otherwise the parent control properties are used.

Best regards,
Juraj Ondrus

User avatar
Member
Member
jenf-deschutes - 12/19/2013 2:52:45 PM
   
RE:Repeater nested in transformation
Here's the code in the nested transformation:

<p class="dcLandingPgColumn"><%# Eval("DocumentName") %></p> 
<ul class="quicklinks">
<cms:CMSRepeater ID="uxArticleLinks" DelayedLoading="true" path="{%# Eval('NodeAliasPath') %}" runat="server" ClassNames="CMS.Article" TransformationName="custom.dcsp.getArticleDesc" OrderBy="NodeOrder" />
</ul>


I added the "DelayedLoading" property today and it doesn't seem to make a difference - I get the same behavior with or without it. I also tried adding it to the CMSUniView statement (in the page template file) and it also didn't make a difference.

1. When the page is loading using the code above, no articles are returned.
2. I've tried using macros found on the "Path specification in controls and web parts" page in the Kentico 7 CMS Controls document - they also return no data.
3. If I change the "path" value to "./%" OR remove the "path" property it returns a list of all articles from the parent path.
4. If I provide a "hard coded" path followed by the "%" operator I get a list of articles - but it isn't dynamic for obvious reasons, and therefore it doesn't meet the needs.

Thanks,
Jen

User avatar
Member
Member
kentico_davidb2 - 12/22/2013 1:13:12 PM
   
RE:Repeater nested in transformation
Well, using nested repeaters is not a good idea - hierarchical viewers have much better performance.

But if you need to keep nested repeaters for some reason, I usually get better results binding the Path within OnInit:
<hr />
<%# Eval("FirstName")%> <%#Eval("LastName")%>

<cms:CMSRepeater
ID="nestedRPT"
DelayedLoading="true"
DataBindByDefault="false"
EnableViewState="false"
runat="server"
Path="/%"
TransformationName="custom.person.for_nested"
ClassNames="custom.person"
HideControlForZeroRows="false"
ZeroRowsText="Nobody"
/>

<script runat="server">
protected override void OnInit(EventArgs e) {
nestedRPT.Path="/%";
nestedRPT.WhereCondition="LastName LIKE '%" + Eval("LastName").ToString().Replace("'","_").Replace("’","_") + "%'";
nestedRPT.ReloadData(true);
}</script>

<hr />

Dave

User avatar
Member
Member
jenf-deschutes - 12/24/2013 1:20:46 PM
   
RE:Repeater nested in transformation
Hi Dave -

If you read my original post, the main page is, in fact, using a hierarchical viewer. Is there a way to restrict a hierarchical viewer to only show child items for certain document types without using a nested repeater?

In short:
Parent: Article 1, Child: Article 2 (don't display Article 2)
Parent: Folder A, Child: Article B (DO display Article B)

Thanks.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/26/2013 6:52:28 AM
   
RE:Repeater nested in transformation
http://devnet.kentico.com/docs/devguide/index.html?registering_cutom_macro_methods.htm
jenf-deschutes wrote: Is there a way to restrict a hierarchical viewer to only show child items for certain document types without using a nested repeater?
You can use a combination of the Max relative levels and Document class names. You could also write your own macro method.

User avatar
Member
Member
jenf-deschutes - 12/24/2013 1:30:24 PM
   
RE:Repeater nested in transformation
Another piece of info that might be useful - if I put the statement "<%# Eval("NodeAliasPath") %>" in the code for the transformation used in the hierarchical viewer it does return the correct path (that I want the repeater to use).

It just appears that the *macro* is not working (in the path statement for the repeater).

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/25/2013 7:28:59 AM
   
RE:Repeater nested in transformation
Hello,

Macros are not supposed to be resolved this way in the code-behind. If you are willing to resolve macros in the in the code, you will need to use the Macros resolver, take a look at a whole section in the Dev Guide: Resolving macros using the API

Best regards,
Martin Danko

User avatar
Member
Member
jenf-deschutes - 12/26/2013 5:04:26 PM
   
RE:Repeater nested in transformation
Sorry, I didn't mean that I was trying to add the macro in the code behind. The macro is in a transformation. I added that line of code to the transformation so that I could confirm that it was (in theory) returning the correct data.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/26/2013 6:54:13 AM
   
RE:Repeater nested in transformation
What is it returning and what are you expecting?

NodeAliasPath returns the value of the document being rendered by the viewer similar to GetDocumentUrl(). The CMSContext.CurrentDocument.NodeAliasPath returns the value of the document you are navigating to no matter what document is being rendered in your viewer.

User avatar
Member
Member
jenf-deschutes - 12/26/2013 5:10:25 PM
   
RE:Repeater nested in transformation
Yes. The NodeAliasPath statement returns the text that I want for the path="{%# Eval('NodeAliasPath') %}" parameter.

I'm having other issues with path statements, both in this transformation and also in aspx templates. For example, Kentico Support has told me that Path="/{0}/%" should be returning the equivalent of Path=”/Clerk-s-Office-(1)/%” in my environment. But the first returns no data while the other does.

Curiouser and curiouser.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/27/2013 6:54:33 AM
   
RE:Repeater nested in transformation
Where are you using Path="/{0}/%"? In a transformation?

Did you know if you leave the Path property blank it will return all the documents below the current level? So if you want to always return the document type Article but only ever want to display 1 level below and have multiple levels then simply leave the Path field empty and set the Max relative levels to 1.

Have you implemented the method in the transformation that Dave mentioned
<script runat="server">
protected override void OnInit(EventArgs e)
{
nestedRPT.Path = Eval("NodeAliasPath") + "/%"; // if you only return NodeAliasPath it will return something like /About-Us/Office1 and you need /About-Us/Office1/% to get all the items below Office1
nestedRPT.ReloadData(true);
}
</script>
It appears your code for your nested repeater is incorrect if you are only using Eval("NodeAliasPath") because that will only return the current document and not have the trailing / and % you need to get everything below that level.

User avatar
Member
Member
jenf-deschutes - 12/27/2013 11:59:24 AM
   
RE:Repeater nested in transformation
I'm using Path="/{0}/%" in an ASPX template (see the bottom of this response).

I know you can leave Path blank or omit it. I've been experimenting with all the different permutations and posted what happened to be "current" at that moment. In the pseudocode in the original post I did include the trailing "/%".

For the path in the original code block...
<p class="dcLandingPgColumn"><%# Eval("DocumentName") %></p> 
<ul class="quicklinks">
<cms:CMSRepeater
ID="uxArticleLinks"
DelayedLoading="true"
path="{%# Eval('NodeAliasPath') %}"
runat="server"
ClassNames="CMS.Article"
TransformationName="custom.dcsp.getArticleDesc"
OrderBy="NodeOrder" />
</ul>
... I've tried both path="{%# Eval('NodeAliasPath') %}" and path="{%# Eval('NodeAliasPath') %}/%"... among other options. The results were:

- path="{%# Eval('NodeAliasPath') %}" renders all the articles under the current page in the content tree (not the current item being rendered).
- path="{%# Eval('NodeAliasPath') %}/%" renders no data.

I did try using the code from Dave, but it didn't work. I used yours (FroggEye's) and changed "nestedRPT" to "uxArticleLinks" to match my code... and *that* is working. (Yay! Thank you!) So, the problem in my original post about the nested repeater is resolved (as long as the viewer allows javascript).

The other issue.

I'm still working through the "new but similar" issue where Path="/{0}/%" in an ASPX template doesn't work - but explicitly stating the path (like: Path=”/Clerk-s-Office-(1)/%”) does work.

This is the "goal code" which would output all the documents starting at the root of the current node...
<cms:CMSUniView 
ID="uxNavFlyoutMenu"
runat="server"
LoadHierarchicalData="True"
HierarchicalTransformationName="DeschutesOrg.dcNavControls.HierarchicalNavMenu"
Path="/{0}/%" />
... and the results of my experimentation:

- If the path property is omitted, I get the children for the current item.
- If I use Path="." I get the current item.
- If I use Path="/{0}/%" I get no data.
- If I use Path=”/Clerk-s-Office-(1)/%” I get what I would expect to see when I use Path="/{0}/%".

(Clear as mud, right?)

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/28/2013 6:28:35 PM
   
RE:Repeater nested in transformation
It's clear to me actually. :) I don't believe you have an understanding of what needs to be done here. To add more fuel to the fire (sorry I have to ask, just curious), any particular reason you're using ASPX templates vs. Portal?

Since the Repeater is nested in another control (and the page lifecycle of the controls is different from what standard asp.net controls is) you need to add the method I posted earlier in order to rebind that data for the repeater, you can't simply set the Path="<%# Eval("NodeAliasPath") %", it won't work as you've already seen. My guess why /{0}/% isn't working is because you need to rebind repeater for each record in the UniView, again, use the method I mentioned above already.

Regarding the uniview control, if you leave the path blank you stated it displays what you'd expect BUT it displays all levels. If you set the MaxRelativeLevel property to 1, it will only get the level directly below the current page you are on. So if you're structure was like so:

-Page1
--Sub1
--Sub2
---Detail1
---Detail2
-Page2
--Sub1
---Detail1
---Detail2
--Sub2

If you're on Page1, it will only display Sub1 and Sub2, if you're on Sub2, it will only display Detail1 and Detail2.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/28/2013 6:31:08 PM
   
RE:Repeater nested in transformation
One other suggestion I might give is getting the UniView working on its own and getting the Repeater working on its own, then combine them. I beleive the key for you is adding that method I mentioned already to get the repeater working inside the UniView.