/// <summary> /// Gets the section. /// </summary> /// <param name="sectionItem">The section item.</param> /// <param name="entity">The data entity.</param> /// <returns>the section.</returns> public static List<SectionTableRow> GetSection(Item sectionItem, object entity) { if (sectionItem != null) { ChildList childList = sectionItem.Children; var tableRows = new List<SectionTableRow>(); foreach (Item sectionFieldItem in childList) { var sectionTableRow = new SectionTableRow(); string title = Utils.ItemUtil.GetTitleOrDictionaryEntry(sectionFieldItem, false); sectionTableRow.Label = title; string fieldID = sectionFieldItem["Field"]; string fieldName = title; string value = fieldID; object obj = new object(); if (!sectionFieldItem.TemplateName.Equals("Footer Section Multi-Line Text Field") && !sectionFieldItem.TemplateName.Equals("Footer Section Text Field") && !sectionFieldItem.TemplateName.Equals("Footer Section Link Field")) { fieldName = GetTemplateFieldName(fieldID); obj = GetSourceObject(fieldID, entity); value = GetPropertyValue(fieldName, obj); } sectionTableRow.FieldName = fieldName; sectionTableRow.ShowLabelColumn = sectionFieldItem.Parent["Show Label Column"] == "1"; sectionTableRow.HideField = sectionFieldItem["Hide Field"] == "1"; sectionTableRow.ShowLabel = sectionFieldItem["Show Label"] == "1"; if (sectionFieldItem.TemplateName.Equals("Order Section Field") || sectionFieldItem.TemplateName.Equals("Footer Section Field") || sectionFieldItem.TemplateName.Equals("Footer Section Multi-Line Text Field") || sectionFieldItem.TemplateName.Equals("Footer Section Text Field")) { if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + ": " + value; } else { sectionTableRow.Value = value; } } else if (sectionFieldItem.TemplateName.Equals("Order Section Double Field") || sectionFieldItem.TemplateName.Equals("Footer Section Double Field")) { string fieldID2 = sectionFieldItem["Field2"]; string fieldName2 = GetTemplateFieldName(fieldID2); string value2 = GetPropertyValue(fieldName2, obj); sectionTableRow.FieldName2 = fieldName2; if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + ": " + value + ", " + value2; } else { sectionTableRow.Value = value + ", " + value2; } } else if (sectionFieldItem.TemplateName.Equals("Footer Section Link Field")) { if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + " " + "<a href=\"" + value + ".aspx\">" + title + "</a>"; } else { sectionTableRow.Value = "<a href=\"" + value + ".aspx\">" + title + "</a>"; } } // To not add the row if HideField is enabled. if (!sectionTableRow.HideField) { tableRows.Add(sectionTableRow); } } return tableRows; } return null; }
/// <summary> /// Gets the section. /// </summary> /// <param name="sectionItem">The section item.</param> /// <param name="entity">The data entity.</param> /// <returns>the section.</returns> public static List <SectionTableRow> GetSection(Item sectionItem, object entity) { if (sectionItem != null) { ChildList childList = sectionItem.Children; var tableRows = new List <SectionTableRow>(); foreach (Item sectionFieldItem in childList) { var sectionTableRow = new SectionTableRow(); string title = Utils.ItemUtil.GetTitleOrDictionaryEntry(sectionFieldItem, false); sectionTableRow.Label = title; string fieldID = sectionFieldItem["Field"]; string fieldName = title; string value = fieldID; object obj = new object(); if (!sectionFieldItem.TemplateName.Equals("Footer Section Multi-Line Text Field") && !sectionFieldItem.TemplateName.Equals("Footer Section Text Field") && !sectionFieldItem.TemplateName.Equals("Footer Section Link Field")) { fieldName = GetTemplateFieldName(fieldID); obj = GetSourceObject(fieldID, entity); value = GetPropertyValue(fieldName, obj); } sectionTableRow.FieldName = fieldName; sectionTableRow.ShowLabelColumn = sectionFieldItem.Parent["Show Label Column"] == "1"; sectionTableRow.HideField = sectionFieldItem["Hide Field"] == "1"; sectionTableRow.ShowLabel = sectionFieldItem["Show Label"] == "1"; if (sectionFieldItem.TemplateName.Equals("Order Section Field") || sectionFieldItem.TemplateName.Equals("Footer Section Field") || sectionFieldItem.TemplateName.Equals("Footer Section Multi-Line Text Field") || sectionFieldItem.TemplateName.Equals("Footer Section Text Field")) { if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + ": " + value; } else { sectionTableRow.Value = value; } } else if (sectionFieldItem.TemplateName.Equals("Order Section Double Field") || sectionFieldItem.TemplateName.Equals("Footer Section Double Field")) { string fieldID2 = sectionFieldItem["Field2"]; string fieldName2 = GetTemplateFieldName(fieldID2); string value2 = GetPropertyValue(fieldName2, obj); sectionTableRow.FieldName2 = fieldName2; if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + ": " + value + ", " + value2; } else { sectionTableRow.Value = value + ", " + value2; } } else if (sectionFieldItem.TemplateName.Equals("Footer Section Link Field")) { if (sectionTableRow.ShowLabel && !sectionTableRow.ShowLabelColumn) { sectionTableRow.Value = title + " " + "<a href=\"" + value + ".aspx\">" + title + "</a>"; } else { sectionTableRow.Value = "<a href=\"" + value + ".aspx\">" + title + "</a>"; } } // To not add the row if HideField is enabled. if (!sectionTableRow.HideField) { tableRows.Add(sectionTableRow); } } return(tableRows); } return (null); }