Developer forum

Forum » Development » Get Items by page id

Get Items by page id

Alec Stubbs
Reply

Hi folks,

I'm struggerling to get items out of DW. The items have been created using the model first way so don't have a CLR type. They are all on one page as paragraph items and the item type system name for them is "Activity"

I've tried two ways to get them but neither is working.

            ItemManager.Initialize();
            using (var repo = ItemManager.Storage.Open("Activity"))
            {
               var myItems =  repo.SelectByPageId(2530); // 0 items returned?
 
            }


            var items = new ItemCollection();
            items = ItemManager.Storage.GetByPageId("Activity", 2530);
            return items;

 

Can someone point out what I'm doing wrong?

 

Cheers,

Alec


Replies

 
Vladimir
Reply
This post has been marked as an answer

Hi Alec,

SelectByPageId and GetByPageId functions could return only page items.

But you can use SelectByParentPageId function to return paragraph items:

using (var repo = ItemManager.Storage.Open("Activity"))            
{               
        var myItems =  repo.SelectByParentPageId(2530, null, true, false); //last parameter is used if you want include subpages and their paragraphs
}

Best regards,

Vladimir

Votes for this answer: 1
 
Alec Stubbs
Reply

Thanks Vladimir

 

You must be logged in to post in the forum