Developer forum

Forum » Templates » Paragraph template @GetItemObject(

Paragraph template @GetItemObject(

Dmitrij Jazel
Reply

Hi guys,

I am trying to get an instance of my item that is saved as "item type" property on paragraph item.

While I am in the paragraph template, you can call methods like @GetString("Item.stringvalue") or @GetInteger("item.intvalue") etc...

But if I need to GetItem("Item.myitem") I can't do it like this.

Question - how can I access values from that property item?

 

/Dmitrij

 

P.S. Not sure if there is an easyer way to do this, but something like this would be a really nice way to use it, wou

Dynamicweb.Content.Items.Item propertyItem = GetItemObject("Item.mypropertyItem");
int divsize = propertyItem["divsize"];

 


Replies

 
Dmitrij Jazel
Reply

This "Item.mypropertyitem" appears in loops, but if I try to loop through it, it appears that it's empty :-/ might be just a wrong way of accessing it, But maybe someone has a code example? That would be amazing! :)

/Dmitrij

 
Dmitrij Jazel
Reply

Anyone? :)

 
Nicolai Høeg Pedersen
Reply

Hi Dmitrij

Try this one:

Dynamicweb.Content.Items.Item i = Dynamicweb.Content.Items.ItemManager.Storage.GetById(Dynamicweb.Frontend.PageView.Current.CurrentParagraph.ItemType, Dynamicweb.Frontend.PageView.Current.CurrentParagraph.ItemId);

 
Dmitrij Jazel
Reply

Hi Nicolai :)

Hmm... a bit tricky... but I tryed that, this is what I got 

Line 47: 'Dynamicweb.Frontend.PageView.Current()' is a 'method', which is not valid in the given context

And this is my line 47

47 Dynamicweb.Content.Items.Item columnsItem = Dynamicweb.Content.Items.ItemManager.Storage.GetById(Dynamicweb.Frontend.PageView.Current.CurrentParagraph.ItemType, Dynamicweb.Frontend.PageView.Current.CurrentParagraph.ItemId);

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Current is a method so you need to call it with ():

....Frontend.PageView.Current().CurrentParagraph.ItemType

Hope this helps,

Imar

 

You must be logged in to post in the forum