Hi can any one tell me why this dosnt work in a Razor template?
@using System.Collections.Generic;
@using Dynamicweb.Content.Items;
@using Dynamicweb.Content.Items.Queries;
@{
IEnumerable<Item> allItems = null;
ItemManager.Initialize();
using (var repository = ItemManager.Storage.Open("Category"))
{
var query = new Query();
query.Fields = new List<string>() { "Sort", "Id", "Category_Name", "Category_Description", "Category_Image", "Category_Page" };
query.OrderBy = new OrderByCollection();
query.OrderBy.Add(new OrderBy("Category_Name", OrderByDirection.Ascending));
query.Offset = 0;
query.Amount = 1000;
allItems = repository.SelectByPageId(227, query);
}
}
@if (allItems != null)
{
<p>allItems not null!</p>
<ol>
@foreach (var item in allItems)
{
<li>@item["Category_Name"] (sort: @item["Sort"]) NEW STUFF</li>
}
</ol>
}
PageID 227 has 7 ItemTypes of type Category and is published
I also tried the following with the noted results:
IEnumerable<ItemEntry> f = ItemManager.Storage.GetByPageId("Category", 227); // returns null
ItemCollection fa = ItemManager.Storage.GetByPageId("Category", 227); // returns null
IEnumerable<Item> fb = ItemManager.Storage.GetByPageId("Category", 227); // returns null
Item i = ItemManager.Storage.GetById("Category", "264"); // Gets the Item type by its Id returns one Item Type
ItemCollection cd = ItemManager.Storage.GetByParagraphId("Category", 23003);// Gets the item type by its containing paragraph
Enterprise version 8.3.1.18