Last active
December 24, 2015 23:59
-
-
Save jondjones/6884044 to your computer and use it in GitHub Desktop.
EPiServer 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// </summary> | |
/// <param name="pageReference"></param> | |
/// <param name="isInEditMode"></param> | |
/// <returns></returns> | |
public static IEnumerable<PageData> GetChildren(PageReference pageReference, bool isInEditMode) | |
{ | |
IEnumerable<PageData> pages = null; | |
try | |
{ | |
var helper = new EpiPageHelper(); | |
if (isInEditMode) | |
{ | |
// Get all unpublished child pages | |
var missingDataPages = DataFactory.Instance.GetChildren(pageReference, LanguageSelector.AutoDetect(true)); | |
// As EPI has a missing meta-data bug we need to get all data before anythign else | |
var editorPages = missingDataPages.Select(x => helper.GetLastestVersion(x.PageLink)); | |
pages = editorPages.Where(item => item.VisibleInMenu && helper.HasAccess(item)); | |
} | |
else | |
{ | |
pages = GetPublicPages(pageReference); | |
} | |
} | |
catch (Exception ex) | |
{ | |
Logger.Error(ex); | |
} | |
return pages; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pageId = 1; | |
var pageRef = new PageReference(pageId ); | |
var page = DataFactory.Instance.GetPage(pageRef) as PageType; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment