Developer forum

Forum » Development » GetItemList in DW 8

GetItemList in DW 8

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I know it's a bit old school, but I need a decent way to get the content of an ItemRelation list that is set on the PageItem.

I can get the ID of the page, I can probably get the Item for that page but I don't know how to get the ItemRelation list content.

Searching through the DW8 API is not very straight forward. I am thinking somebody else must've been stumbled on this thing before :)

Thank you,

Adrian


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

If you take a look at Rizzo for DW8 sources, you should find an example for social networks (which were a list in the website settings). The code is in the Master.cshtml template directly in the design folder.

 

You can find that in the Rizz8 branch in our GitHub account. Here's a quick example

@foreach (var socialItem in GetLoop("Item.Area.SocialNetworks"))
{
// YOUR CODE HERE
}

 

Let me know if you have any more questions.

Best Regards,

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

Thank you,

Unfortunately, I don't have direct access to GetLoop becuase I can't access the Item object directly.

All I have is a page ID. I have to get the Item for that page and then the ItemRelation list id and for that listID I need a loop of Items.

Adrian

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian

 

Then I don't remember of how we did that. If remember correctly on the Item you'd get a comma splitted value of ID's and you had to use GetItemById on each iteration of that value after splitting it by commas.

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

That's what I recall as well.

I was hoping there will be a Method that will render the list without so much trouble.

Anyway, I ended up with a direct query to the database instead.

Less friction :)

Thank you,

Adrian

 

You must be logged in to post in the forum