Summer in the woods

So fast. So agile. So stable. So comfortable

This chromoly-loaded bike takes to the air with incredible ease yet is built tough to absorb those inevitable hard landings.

 

Shop now
Error compiling template "Designs/Swift/Swift_Newsletter/Paragraph/Swift_NewsletterProductCatalog.cshtml"
Line 39: The name 'RenderTwoCol' does not exist in the current context
Line 44: The name 'RenderOneCol' does not exist in the current context
Line 50: The name 'helper' does not exist in the current context
Line 58: The name 'RenderProduct' does not exist in the current context
Line 58: The name 'product' does not exist in the current context
Line 60: The name 'helper' does not exist in the current context
Line 62: No overload for method 'Write' takes 0 arguments
Line 74: The name 'RenderProduct' does not exist in the current context
Line 74: The name 'product' does not exist in the current context
Line 76: No overload for method 'Write' takes 0 arguments
Line 78: The name 'helper' does not exist in the current context
Line 108: The name 'bodyFontStyle' does not exist in the current context
Line 117: The name 'foregroundColor' does not exist in the current context
Line 121: The name 'link' does not exist in the current context
Line 130: The name 'width' does not exist in the current context
Line 133: The name 'product' does not exist in the current context
Line 136: The name 'product' does not exist in the current context
Line 143: The name 'headerFontStyle' does not exist in the current context
Line 147: The name 'product' does not exist in the current context
Line 149: The name 'product' does not exist in the current context

1 // <auto-generated/> 2 #pragma warning disable 1591 3 namespace CompiledRazorTemplates.Dynamic 4 { 5 #line hidden 6 using System.Threading.Tasks; 7 using System; 8 using System.Collections.Generic; 9 using System.Linq; 10 using Dynamicweb.Content; 11 using Dynamicweb.Content.Items; 12 using Dynamicweb.Ecommerce.ProductCatalog; 13 using Page = Dynamicweb.Content.Page; 14 internal class RazorEngine_ef4aad0efbb640bba3eced0d106d71f9 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 15 { 16 #pragma warning disable 1998 17 public async override global::System.Threading.Tasks.Task ExecuteAsync() 18 { 19 20 ProductListViewModel selectedProductList = Model.Item?.GetValue("Products") as ProductListViewModel; 21 string backgroundColor = !string.IsNullOrEmpty(GetSelectedTheme()) ? GetThemeValue("BackgroundColor") : "transparent"; 22 WriteLiteral("\r\n<td"); 23 BeginWriteAttribute("style", " style=\"", 5454, "\"", 5518, 5); 24 WriteAttributeValue("", 5462, "padding:", 5462, 8, true); 25 WriteAttributeValue("", 5470, GetPadding(), 5470, 13, false); 26 WriteAttributeValue("", 5483, ";background-color:", 5483, 18, true); 27 WriteAttributeValue("", 5501, backgroundColor, 5501, 16, false); 28 WriteAttributeValue("", 5517, ";", 5517, 1, true); 29 EndWriteAttribute(); 30 WriteLiteral(">\r\n"); 31 if (selectedProductList != null) 32 { 33 IList<ProductViewModel> products = selectedProductList.Products; 34 35 if (products.Any()) 36 { 37 if (IsTwoColLayout()) 38 { 39 Write(RenderTwoCol(products)); 40 41 } 42 else 43 { 44 Write(RenderOneCol(products)); 45 46 } 47 } 48 } 49 WriteLiteral("</td>\r\n\r\n"); 50 Write(helper); 51 WriteLiteral(@" RenderOneCol(IList<ProductViewModel> products) 52 { 53 foreach (var product in products) 54 { 55 <div class=""layout__inner"" style=""margin-bottom:10px;border-collapse: collapse;display: table;width: 100%;""> 56 <!--[if (mso)|(IE)]><table align=""center"" cellpadding=""0"" cellspacing=""0"" role=""presentation""><tr><td style=""width: 290px"" valign=""top"" class=""w250""><![endif]--> 57 "); 58 Write(RenderProduct(product)); 59 WriteLiteral("\r\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]-->\r\n\t\t</div>\r\n\t}\r\n}\r\n\r\n"); 60 Write(helper); 61 WriteLiteral(" RenderTwoCol(IList<ProductViewModel> products)\r\n{\r\n\tint index = 1;\r\n\tforeach (var product in products)\r\n\t{\r\n\t\tbool isFirstProductInRow = index % 2 != 0;\r\n\r\n\t\tif (isFirstProductInRow)\r\n\t\t{\r\n\t\t\t"); 62 Write(); 63 WriteLiteral(@":<div class=""layout__inner"" style=""margin-bottom:10px;border-collapse: collapse;display: table;width: 100%;""> 64 <!--[if (mso)|(IE)]><table align=""center"" cellpadding=""0"" cellspacing=""0"" role=""presentation""><tr><td style=""width: 290px"" valign=""top"" class=""w250""><![endif]--> 65 } 66 67 if (!isFirstProductInRow) 68 { 69 <!--[if (mso)|(IE)]></td><td style=""width: 20px""><![endif]--> 70 <div class=""gutter"" style=""Float: left;width: 20px;"">&nbsp;</div><!--[if (mso)|(IE)]></td><td style=""width: 290px"" valign=""top"" class=""w250""><![endif]--> 71 } 72 73 "); 74 Write(RenderProduct(product)); 75 WriteLiteral("\r\n\t\t\r\n\t\tif (!isFirstProductInRow || index == products.Count)\r\n\t\t{\r\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]-->\r\n\t\t\t"); 76 Write(); 77 WriteLiteral(":</div>\r\n\t\t}\r\n\t\tindex++;\r\n\t}\r\n}\r\n\r\n"); 78 Write(helper); 79 WriteLiteral(@" RenderProduct(ProductViewModel product) 80 { 81 82 string detailPageId = Model.Item.GetLink(""ProductDetailsPage"") != null ? Model.Item.GetLink(""ProductDetailsPage"").PageId.ToString() : """"; 83 string productPageByNavigationTag = GetPageIdByNavigationTag(""ProductDetailPage"") != 0 ? GetPageIdByNavigationTag(""ProductDetailPage"").ToString() : """"; 84 detailPageId = detailPageId == """" ? productPageByNavigationTag : detailPageId; 85 86 var defaultGroupId = product.PrimaryOrDefaultGroup.Id; 87 var selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(defaultGroupId)?.Meta.PrimaryPage ?? string.Empty; 88 89 string link = string.IsNullOrEmpty(selectedDetailPage) ? $""/Default.aspx?ID={detailPageId}&groupid={defaultGroupId}"" : selectedDetailPage; 90 link += ""&productid="" + product.Id; 91 link += !string.IsNullOrEmpty(product.VariantId) ? ""&variantid="" + product.VariantId : """"; 92 93 string foregroundColor = !string.IsNullOrEmpty(GetSelectedTheme()) ? GetThemeValue(""ForegroundColor"") : ""#000000""; 94 string width = Get"); 95 WriteLiteral(@"ImageRatio() == ""original"" ? """" : ""width:100%""; 96 string bodyFontStyle = GetFontStyle(""Body""); 97 string headerFontStyle = GetFontStyle(""Header""); 98 99 <div class=""column product-column"" style=""max-width: 320px;min-width: 290px; width: 320px;width: calc(18290px - 3000%);Float: left;""> 100 <table style=""border-collapse: collapse;table-layout: fixed;"" cellpadding=""0"" cellspacing=""0"" width=""100%"" role=""presentation""> 101 <tbody> 102 <tr> 103 <td"); 104 BeginWriteAttribute("style", " style=\"", 8689, "\"", 8737, 4); 105 WriteAttributeValue("", 8697, "padding:", 8697, 8, true); 106 WriteAttributeValue("", 8705, GetPadding(true), 8705, 17, false); 107 WriteAttributeValue("", 8722, ";", 8722, 1, true); 108 WriteAttributeValue("", 8723, bodyFontStyle, 8723, 14, false); 109 EndWriteAttribute(); 110 WriteLiteral(">\r\n\t\t\t\t\t\t<a"); 111 BeginWriteAttribute("style", " style=\"", 8749, "\"", 8835, 7); 112 WriteAttributeValue("", 8757, "text-decoration:", 8757, 16, true); 113 WriteAttributeValue(" ", 8773, "none;transition:", 8774, 17, true); 114 WriteAttributeValue(" ", 8790, "opacity", 8791, 8, true); 115 WriteAttributeValue(" ", 8798, "0.1s", 8799, 5, true); 116 WriteAttributeValue(" ", 8803, "ease-in;color:", 8804, 15, true); 117 WriteAttributeValue("", 8818, foregroundColor, 8818, 16, false); 118 WriteAttributeValue("", 8834, ";", 8834, 1, true); 119 EndWriteAttribute(); 120 BeginWriteAttribute("href", " href=\"", 8836, "\"", 8848, 1); 121 WriteAttributeValue("", 8843, link, 8843, 5, false); 122 EndWriteAttribute(); 123 WriteLiteral(">\r\n\t\t\t\t\t\t\t<div align=\"left\">\r\n\t\t\t\t\t\t\t\t<img"); 124 BeginWriteAttribute("style", " style=\"", 8891, "\"", 8959, 6); 125 WriteAttributeValue("", 8899, "border:", 8899, 7, true); 126 WriteAttributeValue(" ", 8906, "0;display:", 8907, 11, true); 127 WriteAttributeValue(" ", 8917, "block;height:", 8918, 14, true); 128 WriteAttributeValue(" ", 8931, "auto;max-width:", 8932, 16, true); 129 WriteAttributeValue(" ", 8947, "100%;", 8948, 6, true); 130 WriteAttributeValue("", 8953, width, 8953, 6, false); 131 EndWriteAttribute(); 132 BeginWriteAttribute("alt", " alt=\"", 8960, "\"", 8979, 1); 133 WriteAttributeValue("", 8966, product.Name, 8966, 13, false); 134 EndWriteAttribute(); 135 BeginWriteAttribute("src", " src=\"", 8980, "\"", 9035, 1); 136 WriteAttributeValue("", 8986, GetImageHandlerImage(product.DefaultImage.Value), 8986, 49, false); 137 EndWriteAttribute(); 138 WriteLiteral(">\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div style=\"mso-line-height-rule: exactly;mso-text-raise: 11px;vertical-align: middle;\">\r\n\t\t\t\t\t\t\t\t<h2 class=\"size-16\""); 139 BeginWriteAttribute("style", " style=\"", 9178, "\"", 9293, 5); 140 WriteAttributeValue("", 9186, "margin-top:10px;margin-bottom:0;font-size:", 9186, 42, true); 141 WriteAttributeValue(" ", 9228, "16px;text-align:", 9229, 17, true); 142 WriteAttributeValue(" ", 9245, "left;", 9246, 6, true); 143 WriteAttributeValue("", 9251, headerFontStyle, 9251, 16, false); 144 WriteAttributeValue("", 9267, ";text-transform:uppercase;", 9267, 26, true); 145 EndWriteAttribute(); 146 WriteLiteral(" lang=\"x-size-16\">\r\n\t\t\t\t\t\t\t\t\t<span>"); 147 Write(product.Name); 148 WriteLiteral("</span>\r\n\t\t\t\t\t\t\t\t</h2>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div style=\"mso-line-height-rule: exactly;mso-text-raise: 11px;vertical-align: middle;\">\r\n\t\t\t\t\t\t\t\t<p style=\"Margin-top: 0;Margin-bottom: 0;text-align:left;font-weight:700;\">"); 149 Write(product.Price.PriceFormatted); 150 WriteLiteral("</p>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</a>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n}\r\n"); 151 } 152 #pragma warning restore 1998 153 154 private string GetImageHandlerImage(string imagePath) 155 { 156 double imageWidth = GetImageWidth(); // get from the page 157 string imageRatio = GetImageRatio(); 158 string image = $"/Admin/Public/GetImage.ashx?width={imageWidth}"; 159 string crop = "5"; 160 161 if (imageRatio != "original") 162 { 163 if (!string.IsNullOrEmpty(imageRatio)) 164 { 165 image += $"&height={GetImageHeight(imageRatio, imageWidth)}&fillcanvas=true"; 166 } 167 } 168 169 image += $"&crop={crop}&image={imagePath}"; 170 171 return image; 172 } 173 174 private double GetImageWidth() 175 { 176 int newsletterWidth = Pageview != null ? Dynamicweb.Core.Converter.ToInt32(Pageview.Page.Item["Width"]) : 660; 177 178 GridRow grid = Dynamicweb.Content.Services.Grids.GetGridRowById(Pageview.CurrentParagraph.GridRowId); 179 var spacing = 20; 180 int padding = Convert.ToInt16(Model.Item.GetRawValueString("ContentPadding", "0")); 181 int oneColPadding = padding * 2; 182 double twoColPadding = padding * 1.5; 183 184 if (grid == null) return IsTwoColLayout() ? (newsletterWidth - spacing) / 2 - twoColPadding : newsletterWidth - oneColPadding; 185 186 var definitionId = grid.DefinitionId; 187 188 if (definitionId == "1Column") return IsTwoColLayout() ? (newsletterWidth - spacing) / 2 - twoColPadding : newsletterWidth - oneColPadding; 189 190 var item = Dynamicweb.Content.Services.Items.GetItem(grid.ItemType, grid.ItemId); 191 var spaceBetweenColumns = item["SpaceBetweenColumns"].ToString(); 192 int columnWidth = spaceBetweenColumns != "spacing" ? newsletterWidth / 2 : (newsletterWidth - spacing) / 2; 193 194 return IsTwoColLayout() ? (columnWidth - spacing) / 2 - twoColPadding : columnWidth - oneColPadding; 195 } 196 197 private static double GetImageHeight(string imageRatio, double imageWidth) 198 { 199 string[] ratioValues = imageRatio.Split('-'); 200 double ratio = ratioValues.Length == 2 ? Dynamicweb.Core.Converter.ToDouble(ratioValues[1]) / Dynamicweb.Core.Converter.ToDouble(ratioValues[0]) : 1; 201 return imageWidth * ratio; 202 } 203 204 private string GetImageRatio() 205 { 206 return Model.Item.GetRawValueString("ImageAspectRatio", "original").ToLower(); 207 } 208 209 private bool IsTwoColLayout() 210 { 211 string colLayout = Model.Item.GetRawValueString("Layout", "2col").ToLower(); 212 return colLayout == "2col"; 213 } 214 215 private string GetThemeValue(string systemName) 216 { 217 int themesPageId = Pageview.AreaSettings.GetLink("ThemesPage") != null ? Pageview.AreaSettings.GetLink("ThemesPage").PageId : 0; 218 if (themesPageId == 0) return ""; 219 220 List<Paragraph> themesPageParagraphs = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themesPageId)?.ToList(); 221 string theme = GetSelectedTheme(); 222 Paragraph themeParagraph = themesPageParagraphs?.FirstOrDefault(p => p.Item["Name"].ToString().ToLower().Equals(theme)); 223 if (themeParagraph == null) return ""; 224 string themeValue = themeParagraph.Item[systemName] != null ? themeParagraph.Item[systemName].ToString() : ""; 225 themeValue = themeValue == "" ? "unset" : themeValue; 226 return themeValue; 227 } 228 229 private string GetSelectedTheme() 230 { 231 string theme = !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["Theme"]?.ToString()) ? Pageview.CurrentParagraph.Item["Theme"].ToString().ToLower() : ""; 232 if (!string.IsNullOrEmpty(theme) && theme != "theme default") return theme; 233 234 GridRow grid = Dynamicweb.Content.Services.Grids.GetGridRowById(Pageview.CurrentParagraph.GridRowId); 235 Item item = Dynamicweb.Content.Services.Items.GetItem(grid.ItemType, grid.ItemId); 236 theme = item["Theme"]?.ToString().ToLower(); 237 238 if (!string.IsNullOrEmpty(theme) && theme != "theme default") return theme; 239 240 theme = Dynamicweb.Core.Converter.ToString(Pageview.Page.Item["Theme"])?.ToLower(); 241 return !string.IsNullOrEmpty(theme) && theme != "theme default" ? theme : ""; 242 } 243 244 private string GetFontStyle(string type) 245 { 246 int brandingPageId = Pageview.AreaSettings.GetLink("BrandingPage") != null ? Pageview.AreaSettings.GetLink("BrandingPage").PageId : 0; 247 if (brandingPageId == 0) return ""; 248 249 Page brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId); 250 if (brandingPage == null) return ""; 251 252 string fontStyle = ""; 253 dynamic font = Newtonsoft.Json.JsonConvert.DeserializeObject(brandingPage.Item[type+"Font"].ToString()); 254 if (font != null) { 255 fontStyle += $"font-family:{font.Family}, sans-serif;"; 256 fontStyle += $"font-weight:{font.SelectedVariant};"; 257 } 258 fontStyle += $"text-transform:{brandingPage.Item[type+"Casing"]};"; 259 fontStyle += $"line-height:{brandingPage.Item[type+"LineHeight"]};"; 260 fontStyle += $"letter-spacing:{brandingPage.Item[type+"LetterSpacing"]};"; 261 return fontStyle; 262 } 263 264 private string GetPadding(bool isProductColumn = false) 265 { 266 if (isProductColumn && !IsTwoColLayout()) return "0"; 267 int paddingValue = Convert.ToInt32(Model.Item.GetRawValueString("ContentPadding", "0")); 268 return (IsTwoColLayout() ? paddingValue / 2 : paddingValue) + "px"; 269 } 270 } 271 } 272 #pragma warning restore 1591 273

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Content 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Page = Dynamicweb.Content.Page 6 @functions 7 { 8 private string GetImageHandlerImage(string imagePath) 9 { 10 double imageWidth = GetImageWidth(); // get from the page 11 string imageRatio = GetImageRatio(); 12 string image = $"/Admin/Public/GetImage.ashx?width={imageWidth}"; 13 string crop = "5"; 14 15 if (imageRatio != "original") 16 { 17 if (!string.IsNullOrEmpty(imageRatio)) 18 { 19 image += $"&height={GetImageHeight(imageRatio, imageWidth)}&fillcanvas=true"; 20 } 21 } 22 23 image += $"&crop={crop}&image={imagePath}"; 24 25 return image; 26 } 27 28 private double GetImageWidth() 29 { 30 int newsletterWidth = Pageview != null ? Dynamicweb.Core.Converter.ToInt32(Pageview.Page.Item["Width"]) : 660; 31 32 GridRow grid = Dynamicweb.Content.Services.Grids.GetGridRowById(Pageview.CurrentParagraph.GridRowId); 33 var spacing = 20; 34 int padding = Convert.ToInt16(Model.Item.GetRawValueString("ContentPadding", "0")); 35 int oneColPadding = padding * 2; 36 double twoColPadding = padding * 1.5; 37 38 if (grid == null) return IsTwoColLayout() ? (newsletterWidth - spacing) / 2 - twoColPadding : newsletterWidth - oneColPadding; 39 40 var definitionId = grid.DefinitionId; 41 42 if (definitionId == "1Column") return IsTwoColLayout() ? (newsletterWidth - spacing) / 2 - twoColPadding : newsletterWidth - oneColPadding; 43 44 var item = Dynamicweb.Content.Services.Items.GetItem(grid.ItemType, grid.ItemId); 45 var spaceBetweenColumns = item["SpaceBetweenColumns"].ToString(); 46 int columnWidth = spaceBetweenColumns != "spacing" ? newsletterWidth / 2 : (newsletterWidth - spacing) / 2; 47 48 return IsTwoColLayout() ? (columnWidth - spacing) / 2 - twoColPadding : columnWidth - oneColPadding; 49 } 50 51 private static double GetImageHeight(string imageRatio, double imageWidth) 52 { 53 string[] ratioValues = imageRatio.Split('-'); 54 double ratio = ratioValues.Length == 2 ? Dynamicweb.Core.Converter.ToDouble(ratioValues[1]) / Dynamicweb.Core.Converter.ToDouble(ratioValues[0]) : 1; 55 return imageWidth * ratio; 56 } 57 58 private string GetImageRatio() 59 { 60 return Model.Item.GetRawValueString("ImageAspectRatio", "original").ToLower(); 61 } 62 63 private bool IsTwoColLayout() 64 { 65 string colLayout = Model.Item.GetRawValueString("Layout", "2col").ToLower(); 66 return colLayout == "2col"; 67 } 68 69 private string GetThemeValue(string systemName) 70 { 71 int themesPageId = Pageview.AreaSettings.GetLink("ThemesPage") != null ? Pageview.AreaSettings.GetLink("ThemesPage").PageId : 0; 72 if (themesPageId == 0) return ""; 73 74 List<Paragraph> themesPageParagraphs = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themesPageId)?.ToList(); 75 string theme = GetSelectedTheme(); 76 Paragraph themeParagraph = themesPageParagraphs?.FirstOrDefault(p => p.Item["Name"].ToString().ToLower().Equals(theme)); 77 if (themeParagraph == null) return ""; 78 string themeValue = themeParagraph.Item[systemName] != null ? themeParagraph.Item[systemName].ToString() : ""; 79 themeValue = themeValue == "" ? "unset" : themeValue; 80 return themeValue; 81 } 82 83 private string GetSelectedTheme() 84 { 85 string theme = !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["Theme"]?.ToString()) ? Pageview.CurrentParagraph.Item["Theme"].ToString().ToLower() : ""; 86 if (!string.IsNullOrEmpty(theme) && theme != "theme default") return theme; 87 88 GridRow grid = Dynamicweb.Content.Services.Grids.GetGridRowById(Pageview.CurrentParagraph.GridRowId); 89 Item item = Dynamicweb.Content.Services.Items.GetItem(grid.ItemType, grid.ItemId); 90 theme = item["Theme"]?.ToString().ToLower(); 91 92 if (!string.IsNullOrEmpty(theme) && theme != "theme default") return theme; 93 94 theme = Dynamicweb.Core.Converter.ToString(Pageview.Page.Item["Theme"])?.ToLower(); 95 return !string.IsNullOrEmpty(theme) && theme != "theme default" ? theme : ""; 96 } 97 98 private string GetFontStyle(string type) 99 { 100 int brandingPageId = Pageview.AreaSettings.GetLink("BrandingPage") != null ? Pageview.AreaSettings.GetLink("BrandingPage").PageId : 0; 101 if (brandingPageId == 0) return ""; 102 103 Page brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId); 104 if (brandingPage == null) return ""; 105 106 string fontStyle = ""; 107 dynamic font = Newtonsoft.Json.JsonConvert.DeserializeObject(brandingPage.Item[type+"Font"].ToString()); 108 if (font != null) { 109 fontStyle += $"font-family:{font.Family}, sans-serif;"; 110 fontStyle += $"font-weight:{font.SelectedVariant};"; 111 } 112 fontStyle += $"text-transform:{brandingPage.Item[type+"Casing"]};"; 113 fontStyle += $"line-height:{brandingPage.Item[type+"LineHeight"]};"; 114 fontStyle += $"letter-spacing:{brandingPage.Item[type+"LetterSpacing"]};"; 115 return fontStyle; 116 } 117 118 private string GetPadding(bool isProductColumn = false) 119 { 120 if (isProductColumn && !IsTwoColLayout()) return "0"; 121 int paddingValue = Convert.ToInt32(Model.Item.GetRawValueString("ContentPadding", "0")); 122 return (IsTwoColLayout() ? paddingValue / 2 : paddingValue) + "px"; 123 } 124 } 125 @{ 126 ProductListViewModel selectedProductList = Model.Item?.GetValue("Products") as ProductListViewModel; 127 string backgroundColor = !string.IsNullOrEmpty(GetSelectedTheme()) ? GetThemeValue("BackgroundColor") : "transparent"; 128 } 129 130 <td style="padding:@GetPadding();background-color:@backgroundColor;"> 131 @if (selectedProductList != null) 132 { 133 IList<ProductViewModel> products = selectedProductList.Products; 134 135 if (products.Any()) 136 { 137 if (IsTwoColLayout()) 138 { 139 @RenderTwoCol(products) 140 } 141 else 142 { 143 @RenderOneCol(products) 144 } 145 } 146 } 147 </td> 148 149 @helper RenderOneCol(IList<ProductViewModel> products) 150 { 151 foreach (var product in products) 152 { 153 <div class="layout__inner" style="margin-bottom:10px;border-collapse: collapse;display: table;width: 100%;"> 154 <!--[if (mso)|(IE)]><table align="center" cellpadding="0" cellspacing="0" role="presentation"><tr><td style="width: 290px" valign="top" class="w250"><![endif]--> 155 @RenderProduct(product) 156 <!--[if (mso)|(IE)]></td></tr></table><![endif]--> 157 </div> 158 } 159 } 160 161 @helper RenderTwoCol(IList<ProductViewModel> products) 162 { 163 int index = 1; 164 foreach (var product in products) 165 { 166 bool isFirstProductInRow = index % 2 != 0; 167 168 if (isFirstProductInRow) 169 { 170 @:<div class="layout__inner" style="margin-bottom:10px;border-collapse: collapse;display: table;width: 100%;"> 171 <!--[if (mso)|(IE)]><table align="center" cellpadding="0" cellspacing="0" role="presentation"><tr><td style="width: 290px" valign="top" class="w250"><![endif]--> 172 } 173 174 if (!isFirstProductInRow) 175 { 176 <!--[if (mso)|(IE)]></td><td style="width: 20px"><![endif]--> 177 <div class="gutter" style="Float: left;width: 20px;">&nbsp;</div><!--[if (mso)|(IE)]></td><td style="width: 290px" valign="top" class="w250"><![endif]--> 178 } 179 180 @RenderProduct(product) 181 182 if (!isFirstProductInRow || index == products.Count) 183 { 184 <!--[if (mso)|(IE)]></td></tr></table><![endif]--> 185 @:</div> 186 } 187 index++; 188 } 189 } 190 191 @helper RenderProduct(ProductViewModel product) 192 { 193 194 string detailPageId = Model.Item.GetLink("ProductDetailsPage") != null ? Model.Item.GetLink("ProductDetailsPage").PageId.ToString() : ""; 195 string productPageByNavigationTag = GetPageIdByNavigationTag("ProductDetailPage") != 0 ? GetPageIdByNavigationTag("ProductDetailPage").ToString() : ""; 196 detailPageId = detailPageId == "" ? productPageByNavigationTag : detailPageId; 197 198 var defaultGroupId = product.PrimaryOrDefaultGroup.Id; 199 var selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(defaultGroupId)?.Meta.PrimaryPage ?? string.Empty; 200 201 string link = string.IsNullOrEmpty(selectedDetailPage) ? $"/Default.aspx?ID={detailPageId}&groupid={defaultGroupId}" : selectedDetailPage; 202 link += "&productid=" + product.Id; 203 link += !string.IsNullOrEmpty(product.VariantId) ? "&variantid=" + product.VariantId : ""; 204 205 string foregroundColor = !string.IsNullOrEmpty(GetSelectedTheme()) ? GetThemeValue("ForegroundColor") : "#000000"; 206 string width = GetImageRatio() == "original" ? "" : "width:100%"; 207 string bodyFontStyle = GetFontStyle("Body"); 208 string headerFontStyle = GetFontStyle("Header"); 209 210 <div class="column product-column" style="max-width: 320px;min-width: 290px; width: 320px;width: calc(18290px - 3000%);Float: left;"> 211 <table style="border-collapse: collapse;table-layout: fixed;" cellpadding="0" cellspacing="0" width="100%" role="presentation"> 212 <tbody> 213 <tr> 214 <td style="padding:@GetPadding(true);@bodyFontStyle"> 215 <a style="text-decoration: none;transition: opacity 0.1s ease-in;color:@foregroundColor;" href="@link"> 216 <div align="left"> 217 <img style="border: 0;display: block;height: auto;max-width: 100%;@width" alt="@product.Name" src="@GetImageHandlerImage(product.DefaultImage.Value)"> 218 </div> 219 <div style="mso-line-height-rule: exactly;mso-text-raise: 11px;vertical-align: middle;"> 220 <h2 class="size-16" style="margin-top:10px;margin-bottom:0;font-size: 16px;text-align: left;@headerFontStyle;text-transform:uppercase;" lang="x-size-16"> 221 <span>@product.Name</span> 222 </h2> 223 </div> 224 <div style="mso-line-height-rule: exactly;mso-text-raise: 11px;vertical-align: middle;"> 225 <p style="Margin-top: 0;Margin-bottom: 0;text-align:left;font-weight:700;">@product.Price.PriceFormatted</p> 226 </div> 227 </a> 228 </td> 229 </tr> 230 </tbody> 231 </table> 232 </div> 233 } 234
Afmeld