public PortfolioHelper(SectionPortfolio currPage) { _currPage = currPage; _umbHelper = ContentHelper.GetHelper(); LoadSettings(); //Load categories and portfolio items. if (_hasCategories) { _categoryItems = _currPage.Descendant <FolderGenericCategories>().Children <DGenericCategoryItem>().ToList(); } _portfolioItems = _currPage.Descendants <PagePortfolioItem>().ToList(); //If show counters enabled and categories are enabled, count portfolio items for each category //This is done here to preserve processing if hide categories is enabled. if (_currPage.ShowItemCount && !_currPage.DoNotDisplayCategories) { _categoryItemCount = new Dictionary <int, int>(); //Get only the non-empty categories (GetCategories() gets only categories with items) and count items in each foreach (IPublishedContent categoryItem in this.GetCategories()) { _categoryItemCount.Add( categoryItem.Id, _portfolioItems.Where(x => categoryItem.Id.ToString().IsContainedInCsv(x.Categories)).Count() ); } } }
private void LoadSettings() { //Get user-defined global settings GlobalRandomRelatedNumber = (_currPage.RandomRelatedNumber <= 0)?3:_currPage.RandomRelatedNumber; GlobalDateFormat = (string.IsNullOrEmpty(_currPage.DateFormat)) ? "dd/MM/yyyy" : _currPage.DateFormat; //Get label for "All" category menu option _allOptionLabel = string.IsNullOrEmpty(_currPage.AllOptionLabel)? _umbHelper.GetDictionaryValue("Theme.Gallery.All").ToString() : _currPage.AllOptionLabel; //See if there are any categories defined at all _hasCategories = _currPage.Descendant <FolderGenericCategories>().HasChildren <DGenericCategoryItem>(); //Get number of columns _noOfCols = _currPage.Columns <= 0 ? 2 : _currPage.Columns; //Decide if masonry or grid Masonry = _currPage.Masonry; //Are images spaced? Spacing = _currPage.Spacing; //Get image upscaling UpscaleImages = _currPage.GetPropertyValue <bool>("upscaleImages", false); //Wide page Wide = _currPage.Wide; //Show counters ShowItemCount = _currPage.ShowItemCount; }