private string GetSearchQuery(IRelatedItemsComposition composition) { var searchTerm = composition.RelatedItemsSearchQuery; if (string.IsNullOrWhiteSpace(searchTerm)) { return(composition.GetHeadline()); } return(searchTerm); }
private IEnumerable <string> GetNodeIdsToExcludeFromSearchResults(IRelatedItemsComposition composition) { var nodeIds = new List <string> { composition.Id.ToString() }; if (ExistenceUtility.IsNullOrEmpty(composition.RelatedItems)) { return(nodeIds); } var pickedRelatedItemIds = composition.RelatedItems.Select(x => x.Id.ToString()); nodeIds.AddRange(pickedRelatedItemIds); return(nodeIds); }
public IEnumerable <RelatedItemViewModel> GetViewModels(IRelatedItemsComposition composition, HomePage homePage) { var viewModels = new List <RelatedItemViewModel>(); if (composition.ShowRelatedItems == false) { return(viewModels); } var pickedRelatedItemViewModels = GetPickedRelatedItemViewModels(composition.RelatedItems, homePage); viewModels.AddRange(pickedRelatedItemViewModels); if (viewModels.Count < MaximumRelatedItems) { var excludedNodeIds = GetNodeIdsToExcludeFromSearchResults(composition); var searchQuery = GetSearchQuery(composition); var numberOfItemsToTake = MaximumRelatedItems - viewModels.Count(); var searchedRelatedItemsViewModels = GetSearchQueryRelatedItemViewModels(searchQuery, MaximumNumberOfSearchResults, numberOfItemsToTake, excludedNodeIds, homePage); viewModels.AddRange(searchedRelatedItemsViewModels); } return(viewModels); }
/// <summary>Static getter for Search Query</summary> public static string GetRelatedItemsSearchQuery(IRelatedItemsComposition that) { return(that.GetPropertyValue <string>("relatedItemsSearchQuery")); }
/// <summary>Static getter for Items</summary> public static IEnumerable <IPublishedContent> GetRelatedItems(IRelatedItemsComposition that) { return(that.GetPropertyValue <IEnumerable <IPublishedContent> >("relatedItems")); }
/// <summary>Static getter for Show Related Items</summary> public static bool GetShowRelatedItems(IRelatedItemsComposition that) { return(that.GetPropertyValue <bool>("showRelatedItems")); }