Developer forum

Forum » Development » Get Parent page inside loop of ItemPulbisher

Get Parent page inside loop of ItemPulbisher

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

i am looping pages in an item publisher, and I am trying to get the parent of the current page inside the loop like this

@{
string pageid=@i.GetInteger("ItemPublisher:Global.PageId").ToString();
var page = Dynamicweb.Content.Services.Pages.GetById(pageid);
var parentpage=Dynamicweb.Content.Services.Pages.GetById(page.ParentID);
}

 

But this gives an error like this

'PageService' does not contain a definition for 'GetById' and no accessible extension method...

I know what the message is saying, but I don´t know what gets me the id of the parent page.

Anyone who can help?

/Hans


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Hans

The method is called GetPage - you should see that in your intellisense.

https://doc.dynamicweb.com/apix/api/Dynamicweb.Content.PageService.html#Dynamicweb_Content_PageService_GetPage_System_Int32_

BR Nicolai

 

You must be logged in to post in the forum