Developer forum

Forum » Templates » Dynamicweb.Content.Paragraph - Get itemlist

Dynamicweb.Content.Paragraph - Get itemlist

Dmitrij Jazel
Reply

Hi guys,

am a bit surprised, but it's a bit tricky.

What I have so far is a paragraph object:

var p_list= Dynamicweb.Content.Paragraph.GetParagraphsByPageID(123);
foreach(var p in p_list ){

    <p>@p.ID</p>

    // add snipet here

}

What I needt to do:

I need to access the list of Items - that is a itemList property of this (p) pargraph.

 

I am able to access the "item type of my page" 

var p_item = Dynamicweb.Content.Items.ItemManager.Storage.GetByParagraphId("InfoBox", p.ID);

But that's all, I can't get into item values of it (one of it's properties is my ItemList that I am trying to access),  

 

/Dmitrij


Replies

 
Dmitrij Jazel
Reply

In other words, Imagine when you page a content placeholder on the page - that lists all paragraphs.

That is what my (foreach loop) does.

Than CMS grabs each paragraph (that in this case is "p").

And what I am trying to do - is simpy call something like List<item> myParagraphItemList = GetValue("Item.InfoBox") like I would do in Paragraph template of this paragraph.

And I want to read values out of the items that are saved inside that "infoBox" item field.

/Dmitrij

 
Nicolai Høeg Pedersen
Reply

Hi Dmitrij

When you have your p_item object, you can the values like this: p_item["SystemNameOfField"]

 
Dmitrij Jazel
Reply

hi Nicolai,

Thanks allot for the tip :)

Yes, ok, but what if I have an item property - that is called:

p_item["Subitems"].

Systemname: "Subitems" of type: "Itemlist".

It contains a Itemlist that I must iterate throguh.

 

While I have p_item object - how do I iterate through items that are inside p_item["Subitems"]? :)

/Dmitrij

 

 
Nicolai Høeg Pedersen
Reply

Check the type of the property (typeof) - I guess that it is a Enumerable of sub item item entries

 

You must be logged in to post in the forum