private void AddClassesForColumns(List <HtmlGenericControl> visibleSections) { // Switch to 3 column view if editor selected it, or based on number of boxes var classForAllSections = "two-col"; var columnsProp = CmsUtilities.GetCustomProperty("Columns"); if (columnsProp != null) { if ((columnsProp.Value == "3 columns") || ((String.IsNullOrEmpty(columnsProp.Value) || columnsProp.Value == "Auto") && visibleSections.Count > 8)) { classForAllSections = "three-col"; } } classForAllSections += " landing-section "; bool odd = true; var offsetPair = 1; int len = visibleSections.Count; for (var i = 0; i < len; i++) { // Add odd/even classes to support two column layout var classForThisSection = odd ? "odd" : "even"; odd = !odd; // Add group1,2,3 class to support three column layout classForThisSection += " group" + ((i % 3) + 1); // Add offset pair classes to support alternate styles down 2 columns (divide sections into pairs, offset by 1) if (odd) { offsetPair = (offsetPair == 1) ? 2 : 1; } classForThisSection += " offset-pair" + offsetPair.ToString(CultureInfo.CurrentCulture); // Put the class name on a container element for each item visibleSections[i].Attributes["class"] = classForAllSections + classForThisSection; } }
protected void Page_Load(object sender, EventArgs e) { // Only show placeholders if they're in use HideUnusedSections(); var visibleSections = GetVisibleSections(); // Add classes for sorting into two or three columns AddClassesForColumns(visibleSections); // Format list of links var descriptionsProp = CmsUtilities.GetCustomProperty("Descriptions"); var descriptionsValue = (descriptionsProp != null) ? descriptionsProp.Value : String.Empty; var page = UmbracoContext.Current.ContentCache.GetById(UmbracoContext.Current.PageId.Value); var useLinks = DisplayAsListsOfLinks(descriptionsValue, page.Level); // Look for default content if (this.section1.Visible && !this.desc01.HasContent) { PopulateDefaultContent(listTitle01, this.section1Content, useLinks, this.from1); } if (this.section2.Visible && !this.desc02.HasContent) { PopulateDefaultContent(listTitle02, this.section2Content, useLinks, this.from2); } if (this.section3.Visible && !this.desc03.HasContent) { PopulateDefaultContent(listTitle03, this.section3Content, useLinks, this.from3); } if (this.section4.Visible && !this.desc04.HasContent) { PopulateDefaultContent(listTitle04, this.section4Content, useLinks, this.from4); } if (this.section5.Visible && !this.desc05.HasContent) { PopulateDefaultContent(listTitle05, this.section5Content, useLinks, this.from5); } if (this.section6.Visible && !this.desc06.HasContent) { PopulateDefaultContent(listTitle06, this.section6Content, useLinks, this.from6); } if (this.section7.Visible && !this.desc07.HasContent) { PopulateDefaultContent(listTitle07, this.section7Content, useLinks, this.from7); } if (this.section8.Visible && !this.desc08.HasContent) { PopulateDefaultContent(listTitle08, this.section8Content, useLinks, this.from8); } if (this.section9.Visible && !this.desc09.HasContent) { PopulateDefaultContent(listTitle09, this.section9Content, useLinks, this.from9); } if (this.section10.Visible && !this.desc10.HasContent) { PopulateDefaultContent(listTitle10, this.section10Content, useLinks, this.from10); } if (this.section11.Visible && !this.desc11.HasContent) { PopulateDefaultContent(listTitle11, this.section11Content, useLinks, this.from11); } if (this.section12.Visible && !this.desc12.HasContent) { PopulateDefaultContent(listTitle12, this.section12Content, useLinks, this.from12); } if (this.section13.Visible && !this.desc13.HasContent) { PopulateDefaultContent(listTitle13, this.section13Content, useLinks, this.from13); } if (this.section14.Visible && !this.desc14.HasContent) { PopulateDefaultContent(listTitle14, this.section14Content, useLinks, this.from14); } if (this.section15.Visible && !this.desc15.HasContent) { PopulateDefaultContent(listTitle15, this.section15Content, useLinks, this.from15); } }