Developer forum

Forum » CMS - Standard features » Page ID in item list

Page ID in item list

Nuno Aguiar
Reply

Hi,

 

We are trying to get the pageID in an item list loop (website properties), but it comes out empty.


            foreach(var pages in GetLoop("Item.Area.FooterPages"))
            {
                <div>@RenderPageContent(GetString("Item.Area.Social.Field.PageId"))</div>
            }

So then we tried to get the raw value and split the value

but got duplicate values from time to time (weird), so had to get the Distinct values

            string str_footerPages = GetString("Item.Area.FooterPages");
            foreach(var pages in str_footerPages.Split(','))
            {
                string str_id = Dynamicweb.Content.Items.ItemManager.Storage.GetById("FooterPages", pages.ToString())["Page"].ToString();
              <div>@RenderPageContent(Int32.Parse(str_id))</div>
            }

But got duplicate values from time to time (weird), so had to get the Distinct values

foreach(var pages in str_footerPages.Split(',').Distinct())
{
  ...
}

Are these known bugs, or are we doing something wrong?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Nuno

If an area/website has some properties extended with an item, that item do not have a page id. If that item has a list of other items (i.e. Area.Social) it does not have a page id either. Because they are not pages.

I think I might be missing some context - where is your item?, what is Item.Area.Social? etc.

 
Nuno Aguiar
Reply

Hi Nicolai,

 

When I went over to give you a response, I noticed what was wrong. We were not loading the loop correctly

 

Got it fixed now.

 

You must be logged in to post in the forum