Do any of you guys have any experience of retrieving values from paragraph item fields using ItemManager.Storage.GetById?
I created an item type with system name SortedNewsList and one field called Dato (of type Date). This item type is only enabled for paragraphs:
http://screencast.com/t/MlDjqfmzfnMf
Now, I am using a Razor template for a news list to retrieve the value of the Dato field.
The context of the news list module rendering is a paragraph that is an instance of my paragraph item type just described.
The first lines of my Razor template look like this:
@{
var pageview = Dynamicweb.Frontend.PageView.Current();
var id = pageview.CurrentParagraph.ID;
var item = Dynamicweb.Content.Items.ItemManager.Storage.GetById("SortedNewsList", id.ToString());
var date = item["Dato"];
}
The first two lines are allright. The id variable holds the ID of the current paragraph.
Then I want to use that ID to retrieve the item ( line 3 ) and get the value of the Dato field ( line 4).
But when I try to render @date in the markup, I just get a null reference exception.