Developer forum

Forum » Templates » @RenderItemList and filtering

@RenderItemList and filtering

Thomas Clausen
Reply

Hi

On a website (http://www.vildmedand.dk/da-DK/Opskrifter.aspx) I have two page items - category and recipe.
Each recipe can belong in more then one category.
The categories a recipe belongs to is controlled by a checkbox list generated from the categories in the current website area.

I then generate a sort of accordion menu (using @ItemRenderList and filtering - below), where the categories are listed with the related recipies.

<ul>
    @foreach (var category in GetLoop("ItemPublisher:Items.List")) {
        <li>
            <a href='@category.GetString("ItemPublisher:Item.Url")' data-category-id='@category.GetString("ItemPublisher:Item.Field.Id")'>@category.GetString("ItemPublisher:Item.Navn")</a>

            @RenderItemList(new {
                ItemType = "Opskrifter",
                ListSourceType = "SelfArea",
                ItemFieldsList = "*",
                ListTemplate = "ItemPublisher/List/menu-level2.cshtml",
                ListPageSize = 900,
                ListOrderBy = "Sort",
                ListOrderByDirection = "Ascending",
                Filter = "Kategori contains \""+category.GetInteger("ItemPublisher:Item.Field.Id")+"\""
            })
        </li>
    }
</ul>

My problem is that when I try to filter out recipies related to category #1 it also shows recipies related to category #10, category #11, category #12 and so on.
I can't seem to make the filter specific enough (like "equals" instead of "contains") or find the right filter combination to prevent this.

Does anyone have any suggestions?

Best regards
Thomas


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Thomas

When you have an item, you can get its related items using Razor, see here:

https://github.com/dynamicweb/dwtc15/blob/master/mri/Files/Templates/Designs/Dwtc15/Dwtc15_Session.cshtml

And here: https://github.com/dynamicweb/dwtc15/blob/master/mri/Files/Templates/Designs/Dwtc15/Dwtc15_Speaker.cshtml

That is an example from TC - a speaker have sessions, and a session have speakers. You can also find the item definitions here:

https://github.com/dynamicweb/dwtc15/tree/master/mri/Files/System/Items

BR Nicolai

 

You must be logged in to post in the forum