Пример #1
0
        public CmsPageModel Build(CmsContent article, MenuPageModel.MenuPageContent menu, BannerPageModel banners)
        {
            if (article.ContentItemsAreNullOrEmpty())
            {
                return(null);
            }

            var item = article.Items.FirstOrDefault();

            var pageTypeResult = item.Sys.ContentType.Sys.Id.GetPageType();

            var contentItems = new List <ContentItem>();

            if (item.Fields.Content?.Content == null)
            {
                return(GenerateCmsPageModel(article, item, pageTypeResult, contentItems, null, menu, banners));
            }

            foreach (var contentItem in item.Fields.Content.Content)
            {
                article.ProcessContentNodeTypes(contentItem, contentItems);
                contentItem.ProcessListNodeTypes(contentItems);
                article.ProcessEmbeddedAssetBlockNodeTypes(contentItem, contentItems);
            }

            var parentPage =
                article.Includes.Entry.FirstOrDefault(c => c.Sys.Id.Equals(item.Fields.LandingPage?.Sys?.Id));

            return(GenerateCmsPageModel(article, item, pageTypeResult, contentItems, parentPage, menu, banners));
        }
Пример #2
0
        private static IEnumerable <BannerPageContent> IterateBannerItems(CmsContent banner)
        {
            var banners = new List <BannerPageContent>();

            foreach (var item in banner.Items)
            {
                var bannerModel  = ProcessBanner(item);
                var contentItems = new List <ContentItem>();

                foreach (var contentItem in item.Fields.Content.Content)
                {
                    banner.ProcessContentNodeTypes(contentItem, contentItems);
                    contentItem.ProcessListNodeTypes(contentItems);
                    banner.ProcessEmbeddedAssetBlockNodeTypes(contentItem, contentItems);
                }

                bannerModel.Items = contentItems;

                banners.Add(bannerModel);
            }

            return(banners);
        }