Try our conversational search powered by Generative AI!

Make Html.PropertyFor for ContetArea use FilteredItems?

Vote:
 

Hi!

I am using the PropertyFor to render the content in a ContentArea and that works just fine except that it iterates throught all items withoiut using FilterdItems.

<div class="knowledge-article-related">
    <div class="section-header-related toggle">
        <h4>@Html.Translate("/KnowledgeBank/WhatYouNeed")</h4>
    </div>
    <div class="knowledge-article-related_content inner">
        @if (Model.CurrentContent.ProductsContentArea != null && Model.CurrentContent.ProductsContentArea.FilteredItems.Any())
        {
            @Html.PropertyFor(x => x.CurrentContent.ProductsContentArea, new { CssClass = "knowledge-article-related_item", ChildrenCssClass = "product-card product-card--hori" })
        }
    </div>
</div>

Is there a default way to have the PropertyFor use FilteredItems when redering? I know there are several ways to solve this by building my own DisplayTemplate etc, but I'm looking for a built in way.

Thanks!

/Kristoffer

#247346
Jan 20, 2021 10:53
Vote:
 

Do you have any ContentAreaRenderer in your project? that can be a place where general we retrieve only filtered contents Content area items. and simply use Html.PropertyFor(x=>x.YourContentArea) in rest of the views.

#247353
Jan 20, 2021 13:09
Vote:
 

Hi,

I'm interested to understand the problem here. As far as I'm aware, rendering a ContentArea using Html.PropertyFor() will retrieve the same items as using FilteredItems. What type of items are you seeing that you shouldn't be? Expired/not published items? Items which are personalised with visitor groups? Items the user doesn't have permissions to view?

#247359
Jan 20, 2021 19:54
Vote:
 

Hmm, could it be a bug for then? The PropertyFor gives me empty divs for expired Commerce items, could this maybe be related to Commerce only? Maybe this should have been a post in the Commerce forum. I will try with CMS items and get back to you.

/Kristoffer 

#247360
Jan 20, 2021 20:23
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.