Hi Everyone, I am Trying to Get a specific item by Paragraph id and my code looks like this
@{
var id = GetGlobalValue("Global:Page.ID");
var pageid = int.Parse(id);
foreach (Dynamicweb.Content.Paragraph i in Dynamicweb.Content.Paragraph.GetParagraphsByPageID(pageid)) {
var itemtype = i.ItemType;
var paragraph = i.ID.ToString();
var paragraphid = int.Parse(paragraph);
Collection<Item> items = ItemManager.Storage.GetByParagraphId(itemtype, paragraphid);
foreach (Item n in items) {
@n.Names
}
}
}
But when i render this I get the following error
Exception in template (Designs\Paragraph\ItemNav.cshtml): System.ArgumentException: System name of the target item cannot be an empty string. Parameter name: metadata at Dynamicweb.Content.Items.Queries.Repository..ctor(ItemType metadata) at Dynamicweb.Content.Items.Queries.StorageFactory.CreateRepository(ItemType metadata) at Dynamicweb.Content.Items.Queries.StorageManager.GetByParagraphId(String systemName, Int32 paragraphId) at CompiledRazorTemplates.Dynamic.edefddfdfffdaaaaca.Execute() at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName) at Dynamicweb.Rendering.Template.Output()
What can i do in order to fix this error? or if there is any better way of getting the items from paragraph it will be great.
Please help and many thanks in advance.
Best Regards