Try our conversational search powered by Generative AI!

Best way to get a pageproperty from a parent page

Vote:
 

What is the best/simpliest method if you want to retrieve a pageproperty from a parent page (without specifying page id)? Thankful for help!

#73594
Jul 31, 2013 11:03
Vote:
 

Hi,

We are having an extension method to fetch a parent:

        public static PageData GetParent(this PageData page)
        {
DataFactory.Instance.GetPage(page.ParentLink);
        }

  

(This is for EPi 6, for EPi 7, it's slightly different)

Perhaps I misunderstood you, let me know if this is not what you are looking for.

#73602
Jul 31, 2013 15:45
Vote:
 

Okey, thank you! I found the same solution (without method) a while ago:

PageData oPage = null;

oPage = DataFactory.Instance.GetPage(CurrentPage.ParentLink);

 

or a more secure one:

PageData oPage = null;

if (CurrentPage.ParentLink != EPiServer.Core.PageReference.EmptyReference)
{
oPage = DataFactory.Instance.GetPage(CurrentPage.ParentLink);
}

 

 

#73608
Jul 31, 2013 16:09
Vote:
 

For v7:

 

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var page = contentRepository.Get<PageData>(CurrentPage.ParentLink);

    

#73628
Aug 01, 2013 22:16
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.