Reputation: 290
I'd like to select all contentItems of Fruits contentType and store them into an array for easy access.
public array GetFruitNutrition(int itemId)
{
array fruitsArray = DotNetNuke.Entities.Content.Data.DataService.GetContentItemsByContentType(Fruits);
return fruitsArray[itemId].Nutrition;
}
Are there any ways to make this possible? I'm fine with alternatives too.
Upvotes: 1
Views: 173
Reputation: 155925
Use DotNetNuke.Entities.Content.ContentController.GetContentItemsByContentType
instead of going directly to the data service.
ContentType contentType = new ContentTypeController().GetContentTypes().SingleOrDefault(ct => ct.ContentType == "MyCompany_Fruit");
ContentItem[] fruit = new ContentController().GetContentItemsByContentType(contentType.ContentTypeId).ToArray();
Upvotes: 2