Repeater Transformation with Linked fields (Uni Selector)

Thomas Seyssens asked on May 10, 2016 16:10


We're trying to use a repeater to loop over some items on our website. Those items have a linked item, coupled with a Uni selector.

When using the transformation, and using the Eval() method, we only get the NodeID of the linked item. We actually want a field from the linked item.

<div class="custom-class">
    <p>custom text ... <%# Eval("fieldofcurrentitem") %>, <a href="#"><%# Eval("fieldoflinkeditem") %></a></p>

Anyone who can give us the easiest way to achieve this?

Kind regards! Thomas

Correct Answer

Trevor Fayas answered on May 10, 2016 17:00

Here's the options.

  1. If this repeater's content doesn't change a lot, just on a lot of pages, use Kentico's caching, you can absorb the larger upfront cost and then have it cached.
  2. If the repeater itself has a lot of items it's repeating, consider writing a custom query that gets the page data you desire, joining it with the linked document's fields you want, and then use a Repeater with Custom Query webpart to display it, this means all the linked document's info is pulled in through the join so you have only 1 query instead of 1 main query with a sub query for each row.

Kentico has Debugging, including SQL debugging, i would turn it on, run the page, then take a look at the debugging interface to see how much time / data is being returned for that repeater.

2 votesVote for this answer Unmark Correct answer

Recent Answers

Roman Hutnyk answered on May 10, 2016 16:20

You can write server side code in ASPX transformations like this:

<%# CMS.DocumentEngine.DocumentHelper.GetDocument(Eval<int>("fieldofcurrentitem"), new CMS.DocumentEngine.TreeProvider()).GetValue("fieldName")%>

This is not the best approach performance wise, so you might need to add some caching, or think how to join this data, so you'll get all needed columns in a single database query.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on May 10, 2016 16:23 (last edited on December 10, 2019 02:30)

Along with Roman's suggestion, if you set it to html/xml transformation (so you can use macros) you can do

{% RootDocument.AllChildren.Where("NodeID="+fieldofcurrentitem)[0].GetValue("myfield") |(identity)GlobalAdministrator%}

But just another way to do the same thing.

The other option is to write a query that grabs the linked file's value, then do a repeater off of that custom query, but i would only go that route if the extra pull of information is causing delay (if it's repeating 1-10 items, don't worry about it, if it's repeating 100 items that's 100 more queries which should be modified so it's 1 query that joins that info)

0 votesVote for this answer Mark as a Correct answer

Thomas Seyssens answered on May 10, 2016 16:45

So, the solutions are not ideal if it is a page that will be rendered quite a lot? Are there solutions to make these linked item fields render easily without performance dropping?

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 11, 2016 19:33

Hi Thomas,

What is the source of your data? Custom tables or Page Types.

I am wondering why can't use Hierarchial viewer as it seems like you have a data in hierarchial structure.

Can you explain your use case more and tell me if your data source is one of those? I would give a try.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

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