/// <summary> /// Get the size guide for the product /// </summary> /// <param name="currentContent"></param> /// <returns></returns> protected int GetSizeGuide(FashionProductContent currentContent) { int output = UrlHelpers.GetReferenceFromUrl(currentContent.SizeGuide); if (output > 0) { return(output); } var ancestors = ContentLoader.GetAncestors(currentContent.ContentLink); foreach (var ancestor in ancestors) { var content = ContentLoader.Get <IContent>(ancestor.ContentLink); if (content is FashionStoreSubLandingNodeContent) { output = UrlHelpers.GetReferenceFromUrl(((FashionStoreSubLandingNodeContent)content).SizeGuide); } else if (content is FashionStoreLandingNodeContent) { output = UrlHelpers.GetReferenceFromUrl(((FashionStoreLandingNodeContent)content).SizeGuide); } if (output > 0) { return(output); } } return(-1); }
public override object GetValue(IContent content, PropertyInfo property, Type collectionItemType) { var result = GetPagesCollection( () => ContentLoader.GetAncestors(content.ContentLink), collectionItemType); return(result); }
/// <summary> /// Returns the closest parent to the start page of the given page. /// </summary> /// <remarks> /// Start Page /// - About Us (This is the section) /// - News /// News 1 (= contentLink parameter) /// </remarks> /// <param name="contentLink">The content you want to find the section for</param> /// <returns>The parent page closes to the start page, or the page referenced by the contentLink itself</returns> protected IContent GetSection(ContentReference contentLink) { var currentContent = ContentLoader.Get <IContent>(contentLink); if (currentContent.ParentLink != null && currentContent.ParentLink.CompareToIgnoreWorkID(ContentReference.StartPage)) { return(currentContent); } // Loop upwards until the parent is start page or root return(ContentLoader.GetAncestors(contentLink) .OfType <PageData>() .SkipWhile(x => x.ParentLink == null || !x.ParentLink.CompareToIgnoreWorkID(ContentReference.StartPage)) .FirstOrDefault()); }