public async Task <IEnumerable <ListItem> > GenerateListItemsFromChildren(ScItemsResponse itemsResponse) { List <ListItem> list = new List <ListItem> (); for (int i = 0; i < itemsResponse.ResultCount; i++) { ISitecoreItem item = itemsResponse[i]; if (item == null) { continue; } ListItem listlItem = new ListItem { Header = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title), Text = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Summary), NavigationItem = item.Id, NavigationText = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title), SitecoreItem = item, Media = await _cachedMediaRepository.GetCache(item.GetImageUrlFromMediaField(Constants.Sitecore.Fields.PageContent.Image)) }; list.Add(listlItem); } return(list); }
public async Task <IEnumerable <ListItem> > GenerateListItemsFromTeasers(IList <ScItemsResponse> itemsResponse) { List <ListItem> list = new List <ListItem> (); for (int i = 0; i < itemsResponse.Count(); i++) { if (itemsResponse [i] == null || itemsResponse [i].ResultCount == 0) { continue; } ISitecoreItem item = itemsResponse [i].First(); ListItem listlItem = new ListItem { Header = item.GetValueFromField(Constants.Sitecore.Fields.Teasers.TeaserTitle), Text = item.GetValueFromField(Constants.Sitecore.Fields.Teasers.TeaserSummary), NavigationItem = item.GetItemIdFromLinkField(Constants.Sitecore.Fields.Teasers.TeaserLink), NavigationText = item.GetTextFromLinkField(Constants.Sitecore.Fields.Teasers.TeaserLink), Media = await _cachedMediaRepository.GetCache(item.GetImageUrlFromMediaField(Constants.Sitecore.Fields.Teasers.TeaserImage)) }; list.Add(listlItem); } return(list); }
private async Task SetData(PageData pageData) { ISitecoreItem item = pageData.ItemContext.FirstOrDefault(); base.Title = pageData.NavigationTitle; ContentBody = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Body); ContentHeader = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title); ContentSummary = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Summary); ContentMedia = await _cachedMediaRepository.GetCache(item.GetImageUrlFromMediaField(Constants.Sitecore.Fields.PageContent.Image)); }
private async Task SetData(PageData pageData) { ISitecoreItem item = pageData.ItemContext.FirstOrDefault(); base.Title = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title); ContentHeader = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title); ContentSummary = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Summary); ContentMedia = await _cachedMediaRepository.GetCache(item.GetImageUrlFromMediaField(Constants.Sitecore.Fields.PageContent.Image)); IEnumerable <ListItem> listItems = await _listItemService.GenerateListItemsFromChildren(pageData.DataSourceFromChildren); ListItems = listItems.ToList().AsPairsSafe().ToObservableCollection(); }
public async Task <PageData> GeneratePageData(string itemid, PayloadType itemLoadType, List <ScopeType> itemScopeTypes, string datasourceFieldName, string itemLanguage = "en") { ScItemsResponse response = await GetItemById(itemid, itemLoadType, itemScopeTypes, itemLanguage); if (response == null) { return(null); } ISitecoreItem item = response.First(); if (item == null) { return(null); } PageData pageData = new PageData { PageName = item.DisplayName, ItemContext = response, NavigationTitle = item.GetValueFromField(Constants.Sitecore.Fields.Navigation.NavigationTitle), PageType = item.GetTemplateName(), DataSourceFromChildren = await GetDatasourceFromChildren(item), DataSourceFromField = await GetDataSourceFromFieldName(item, datasourceFieldName) }; return(pageData); }
public async Task <IEnumerable <NavigationMenuItem> > GenerateMenuItems() { Settings settings = await _settingsRepository.GetWithFallback(); PageData rootPageData = await _sitecoreService.GeneratePageData( settings.SitecoreNavigationRootId, PayloadType.Content, new List <ScopeType> () { ScopeType.Self, ScopeType.Children }, Constants.Sitecore.Fields.Teasers.TeaserSelector, settings.SitecoreDefaultLanguage); if (rootPageData == null || rootPageData.ItemContext == null) { return(null); } List <NavigationMenuItem> menuItems = new List <NavigationMenuItem> (); for (int i = 0; i < rootPageData.ItemContext.ResultCount; i++) { ISitecoreItem item = rootPageData.ItemContext [i]; if (item == null) { continue; } NavigationMenuItem menuItem = new NavigationMenuItem { Title = item.GetValueFromField(Constants.Sitecore.Fields.Navigation.NavigationTitle), RowColor = Color.Transparent, PageContext = await GetPageData(item, rootPageData), ShowInMenu = item.GetCheckBoxValueFromField(Constants.Sitecore.Fields.Navigation.ShowInNavigation), IconSource = item.GetValueFromField(Constants.Sitecore.Fields.Navigation.Icon) }; menuItems.Add(menuItem); } return(menuItems); }
private async Task SetData(PageData pageData) { base.Title = "Settings"; UserSettings = await _settingsRepository.GetWithFallback(); if (base.PageContext == null) { return; } base.Title = pageData.NavigationTitle; ISitecoreItem item = pageData.ItemContext.FirstOrDefault(); if (item == null) { return; } ContentHeader = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Title); ContentSummary = item.GetValueFromField(Constants.Sitecore.Fields.PageContent.Summary); }