Kentico - CMS Repeater WhereCondition and DocumentURLPath issue with incorrect path/url

Robert Gliguroski asked on November 10, 2021 15:52

Hi,

I have a custom Web Part which uses <cms:cmsrepeater> with a "WhereCondition" and also "classnames" in order to filter the items. My problem is that when I try to use a dynamically-calculated path for the WhereCondition, I seem to get the incorrect items in the repeater.

I have the following method in the code-behind file for the Web Part:

Image Text

We can see that this method returns the correct path which I then use in the WhereCondition in the ascx file, like this:

Image Text

However, this results in a completely different URL for the Eval("DocumentUrlPath"), like this:

Image Text

If I try to hardcode the path in the WhereCondition, like this:

Image Text

Then I get the correct product attachments(downloads etc.) with the correct href (DocumentUrlPath?):

Image Text

So I'm trying to use the method instead of hardcoding this because obviously it needs to work for any product/page and get the current document path (or whatever else I need to use) - and look into the Downloads etc.. (files under this page) and load them.

Any help would be appreciated

Correct Answer

Juraj Ondrus answered on November 11, 2021 06:04

At first I would like to tell that DocumentURLPath != NodeAliasPath. These two can be different. Not sure if this is also the case. However, it is possible that you are calling the GetParentAliasPath() method too early or too late. So, it will not set the WHERE condition properly.
I would try loading the WHERE condition in the code behind, e.g. in the OnContentLoaded() event. And after setting the property I would also call ReloadData() on the repeater control.

1 votesVote for this answer Unmark Correct answer

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