API Questions on Kentico API.
Version 6.x > API > Blogs By User View modes: 
User avatar
Member
Member
tj-norex - 6/27/2012 12:46:41 PM
   
Blogs By User
Totally new to Kentico (and it's been a few years since .NET, so bear with me). I'm looking to have something where I am listing blogs posts and grouping them by author. I feel like I need to be able to use nested repeaters because I want to output one block of HTML for an author (their avatar, name, etc) and a second block which would contain X number of blog posts for that user. I'd post what I have so far, but I don't seem to even be close (was attempting nested repeaters, one looping through the users, and one through blog posts, but I could not figure out how to pass the where condition to the child repeater properly).

Thanks for your help,
-TJ

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 6/28/2012 1:36:00 PM
   
RE:Blogs By User
Hi,

The nested controls with dynamic where condition scenarios can be tricky.
There were some discussions here in the forums for example.

Generally, you could use something like this in the Users listing transformation:

<cms:CMSRepeater ID="nestedRep" runat="server"
ClassNames="CMS.Blog"
TransformationName="CMS.Blog.preview"
Path="/%" SelectOnlyPublished="true" WhereCondition='<%# "NodeOwner = " + Eval(UserID) %>' />


The where condition (may need some corrections) should select appropriate records, but it is set too late within the controls lifecycle so you will need to reload the data -
the following script has to be a part of the transformation (e.g. at the and of the transformation text):

<script runat="server">

protected override void OnPreRender(EventArgs e)
{
nestedRep.ReloadData(true);
}

</script>


Maybe you could also consider using an alternative - Universal or Hierarchical viewer with Hierarchical transformations, described in DevGuide

Hope it will help.

Regards,
Zdenek