private CmsPageModel GenerateCmsPageModel(CmsContent article, Item item, PageType pageTypeResult, List <ContentItem> contentItems, Entry parentPage, MenuPageModel.MenuPageContent menu, BannerPageModel banners) { return(new CmsPageModel { PageAttributes = new PageModel { Title = item.Fields.Title, Summary = item.Fields.Summary, Slug = item.Fields.Slug, HubType = item.Fields.HubType, MetaDescription = item.Fields.MetaDescription, PageType = pageTypeResult, }, MainContent = new PageContent { Items = contentItems }, Attachments = item.Fields.Attachments?.Select(attachment => article.GetEmbeddedResource(attachment.Sys.Id)) .ToList(), RelatedArticles = article.Includes?.Entry != null ? article .Includes .Entry.Where(c => c.Sys?.ContentType?.Sys?.Type != null && c.Sys.ContentType.Sys.Type.Equals("link", StringComparison.CurrentCultureIgnoreCase) && c.Sys.ContentType.Sys.LinkType.Equals("ContentType", StringComparison.CurrentCultureIgnoreCase) && Enum.TryParse <PageType>(c.Sys.ContentType.Sys.Id, true, out var type) && type == PageType.Article ) .Select(entry => new PageModel { Slug = entry.Fields.Slug, Summary = entry.Fields.Summary, Title = entry.Fields.Title, HubType = entry.Fields.HubType, MetaDescription = entry.Fields.MetaDescription }) .ToList() : new List <PageModel>(), ParentPage = parentPage != null ? new PageModel { Slug = parentPage.Fields.Slug, Title = parentPage.Fields.Title, Summary = parentPage.Fields.Summary, HubType = parentPage.Fields.HubType, MetaDescription = parentPage.Fields.MetaDescription } : null, MenuContent = menu, TabbedContents = ProcessTabbedContent(article, item), BannerModels = banners });
private static void ProcessEmbeddedAssetBlockNodeTypes(CmsContent article, SubContentItems contentItem, List <ContentItem> contentItems) { if (contentItem.NodeType.NodeTypeIsEmbeddedAssetBlock()) { contentItems.Add(new ContentItem { Type = contentItem.NodeType, EmbeddedResource = article.GetEmbeddedResource(contentItem.Data.Target.Sys.Id) }); } }
private static ContentItem ProcessHeaderImage(CmsContent hub, Item item) { if (item.Fields.HeaderImage == null) { return(null); } return(new ContentItem { Type = item.Fields.HeaderImage.Sys.LinkType, EmbeddedResource = hub.GetEmbeddedResource(item.Fields.HeaderImage.Sys.Id) }); }