Passing Entity List to a Razor Function

May 30, 2014 at 12:06 PM
I'm working on a template and I have an item that belongs to multiple categories. I've setup the categories as an entity and assigned multiple values. In my template for each item I want to create a string that has all the category names. I wanted to create a function that would accept the list of categories, iterate through the list and return the string I want. The problem is I'm not sure what data type my function should accept. In my template @Content.Category would be the list of Category Entities but I'm not sure what the data type would be for my function. Any ideas?
May 30, 2014 at 12:48 PM
@using ToSic.Eav.DataSources
var allCategories = CreateSource<EntityTypeFilter>();
    allCategories.TypeName = "Category";

and then to retrieve the values of the category content type
   @foreach (var dict in allCategories.List)
                    var category = AsDynamic(dict.Value);

                        <span data-path=".@category.Class">@category.Title</span>

May 30, 2014 at 12:55 PM
Thank you!