Error executing template "Designs/Rapido/eCom/Productlist/ConfiguratorRender.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_8d1cb876ab8848cb975dc5d516612d60.b__15_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 934
   at CompiledRazorTemplates.Dynamic.RazorEngine_8d1cb876ab8848cb975dc5d516612d60.b__14_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 880
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_8d1cb876ab8848cb975dc5d516612d60.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 169
   at CompiledRazorTemplates.Dynamic.RazorEngine_8d1cb876ab8848cb975dc5d516612d60.<>c__DisplayClass1_0.b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 83
   at CompiledRazorTemplates.Dynamic.RazorEngine_8d1cb876ab8848cb975dc5d516612d60.Execute() in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 875
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Frontend.Devices 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using System 7 @using System.IO 8 @using System.Web 9 @using System.Collections.Generic; 10 @using System.Linq 11 @using System.Text.RegularExpressions 12 @using Dynamicweb.Rapido.Blocks 13 @using Dynamicweb.Ecommerce.Products; 14 15 @functions { 16 BlocksPage productListPage = BlocksPage.GetBlockPage("ProductList"); 17 } 18 19 @{ 20 Block pageContainer = new Block() 21 { 22 Id = "PageContainer", 23 Template = RenderPageContainer(), 24 SkipRenderBlocksList = true 25 }; 26 productListPage.Add(pageContainer); 27 28 Block productListNavigation = new Block() 29 { 30 Id = "Navigation", 31 SortId = 20, 32 Design = new Design 33 { 34 RenderType = RenderType.Column, 35 Size = "0" 36 } 37 }; 38 productListPage.Add("PageContainer", productListNavigation); 39 40 Block productListContainer = new Block() 41 { 42 Id = "ProductList", 43 SortId = 30, 44 Template = RenderProductList(), 45 SkipRenderBlocksList = true 46 }; 47 productListPage.Add("PageContainer", productListContainer); 48 49 Block productListSnippets = new Block() 50 { 51 Id = "BottomSnippets", 52 SortId = 40 53 }; 54 productListPage.Add(productListSnippets); 55 } 56 57 @* This is required for the product list feed to work *@ 58 @GetValue("DoNotRenderProductListTemplate") 59 60 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 61 @using System.Text.RegularExpressions 62 @using System.Collections.Generic 63 @using System.Reflection 64 @using System.Web.UI.HtmlControls 65 @using Dynamicweb.Rapido.Blocks.Components 66 @using Dynamicweb.Rapido.Blocks.Components.Articles 67 @using Dynamicweb.Rapido.Blocks.Components.Documentation 68 @using Dynamicweb.Rapido.Blocks 69 70 71 @*--- START: Base block renderers ---*@ 72 73 @helper RenderBlockList(List<Block> blocks) 74 { 75 blocks = blocks.OrderBy(item => item.SortId).ToList(); 76 77 foreach (Block item in blocks) 78 { 79 <!-- START: @item.Id --> 80 81 if (item.Design == null) 82 { 83 @RenderBlock(item) 84 } 85 else if (item.Design.RenderType == RenderType.None) { 86 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 87 88 <div class="@cssClass dw-mod"> 89 @RenderBlock(item) 90 </div> 91 } 92 else if (item.Design.RenderType != RenderType.Hide) 93 { 94 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 95 96 if (!item.SkipRenderBlocksList) { 97 if (item.Design.RenderType == RenderType.Row) 98 { 99 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 100 @RenderBlock(item) 101 </div> 102 } 103 104 if (item.Design.RenderType == RenderType.Column) 105 { 106 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 107 string size = item.Design.Size ?? "12"; 108 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 109 110 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id"> 111 @RenderBlock(item) 112 </div> 113 } 114 115 if (item.Design.RenderType == RenderType.Table) 116 { 117 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 118 @RenderBlock(item) 119 </table> 120 } 121 122 if (item.Design.RenderType == RenderType.TableRow) 123 { 124 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 125 @RenderBlock(item) 126 </tr> 127 } 128 129 if (item.Design.RenderType == RenderType.TableColumn) 130 { 131 <td class="@cssClass dw-mod" id="Block__@item.Id"> 132 @RenderBlock(item) 133 </td> 134 } 135 136 if (item.Design.RenderType == RenderType.CardHeader) 137 { 138 <div class="card-header @cssClass dw-mod"> 139 @RenderBlock(item) 140 </div> 141 } 142 143 if (item.Design.RenderType == RenderType.CardBody) 144 { 145 <div class="card @cssClass dw-mod"> 146 @RenderBlock(item) 147 </div> 148 } 149 150 if (item.Design.RenderType == RenderType.CardFooter) 151 { 152 <div class="card-footer @cssClass dw-mod"> 153 @RenderBlock(item) 154 </div> 155 } 156 } 157 else 158 { 159 @RenderBlock(item) 160 } 161 } 162 163 <!-- END: @item.Id --> 164 } 165 } 166 167 @helper RenderBlock(Block item) 168 { 169 if (item.Template != null) 170 { 171 @BlocksPage.RenderTemplate(item.Template) 172 } 173 174 if (item.Component != null) 175 { 176 string methodName = item.Component.HelperName; 177 dynamic[] methodParameters = new dynamic[1]; 178 methodParameters[0] = item.Component; 179 Type methodType = this.GetType(); 180 MethodInfo generalMethod = methodType.GetMethod(methodName); 181 182 if (generalMethod != null) { 183 @generalMethod.Invoke(this, methodParameters).ToString(); 184 } else { 185 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked"); 186 } 187 } 188 189 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 190 { 191 @RenderBlockList(item.BlocksList) 192 } 193 } 194 195 @*--- END: Base block renderers ---*@ 196 197 198 @* Include the Blocks for the page *@ 199 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 200 @using Dynamicweb.Core 201 @using System 202 @using System.Web 203 @using System.Collections.Generic 204 @using Dynamicweb.Rapido.Blocks 205 206 @{ 207 BlocksPage productListProductsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 208 209 Block productsBlock = new Block 210 { 211 Id = "Views", 212 SortId = 30, 213 Template = RenderProducts() 214 }; 215 216 productListProductsBlocksPage.Add("ProductList", productsBlock); 217 } 218 219 @helper RenderProducts() 220 { 221 @*This is part of a script template *@ 222 223 <div id="ProductsContainer" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod" data-save-cookie="true"> 224 {{#ProductsContainer}} 225 {{> (lookup . 'template') }} 226 {{/ProductsContainer}} 227 </div> 228 } 229 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 230 @using Dynamicweb.Core 231 @using System 232 @using System.Web 233 @using System.Collections.Generic 234 @using Dynamicweb.Rapido.Blocks 235 236 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableGridView")) 237 { 238 BlocksPage productList = BlocksPage.GetBlockPage("ProductList"); 239 240 Block gridViewButton = new Block 241 { 242 Id = "ProductGridItemContainer", 243 Name = "th", 244 SortId = 20 245 }; 246 productList.Add("Views", gridViewButton); 247 248 249 Block gridViewScripts = new Block 250 { 251 Id = "GridViewScripts", 252 SortId = 20, 253 Template = GridView() 254 }; 255 productList.Add("BottomSnippets", gridViewScripts); 256 } 257 258 @helper GridView() 259 { 260 bool onlyPreview = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("OnlyPreviewForAnonymous") && Pageview.User == null; 261 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 262 bool showPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 263 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fas fa-shopping-cart"; 264 string columnsCount = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetList("Columns") != null ? Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetList("Columns").SelectedValue : "4"; 265 bool showCartButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowAddToCartButton"); 266 bool showViewButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowViewButton"); 267 bool showFavoriteButton = !Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("HideFavoriteButton"); 268 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowAddToDownloadButton"); 269 bool showStock = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowStockAndShipping"); 270 bool showNumber = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowProductNumber"); 271 bool showStaticVariants = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowStaticVariants"); 272 string cartButtonText = Converter.ToInt32(columnsCount) >= 4 && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" ? Translate("Add to cart") : ""; 273 string viewMoreText = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetString("ViewMoreText")) ? Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetString("ViewMoreText") : "View"; 274 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 275 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 276 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 277 string imageZoomOnHover = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 278 bool secondaryImage = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetString("HoverAlternatineImage") != null ? Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("HoverAlternatineImage") : false; 279 string footerClasses = showStaticVariants ? "u-min-h120px" : ""; 280 281 <script id="ProductGridItemContainer" type="text/x-template"> 282 {{#.}} 283 <div id="Product{{id}}" data-template="ProductGridItem" data-preloader="overlay" class="grid__col-lg-@columnsCount grid__col-md-@columnsCount grid__col-sm-@columnsCount grid__col-xs-6 product-list__grid-item @imageZoomOnHover dw-mod"> 284 {{#Product}} 285 {{>ProductGridItem}} 286 {{/Product}} 287 </div> 288 {{/.}} 289 </script> 290 291 <script id="ProductGridItem" type="text/x-template"> 292 {{#.}} 293 @if (useGoogleTagManager) 294 { 295 <text>{{{googleEnchantImpression 'Product catalogue' currency googleImpression}}}</text> 296 } 297 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 298 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 299 300 <div class="grid__cell product-list__grid-item__image dw-mod {{noImage}}"> 301 <img class="grid__cell-img grid__cell-img--centered u-padding b-lazy" src="/Files/Images/placeholder.gif" 302 data-src="/Admin/Public/GetImage.ashx?width=377&amp;height=316&amp;crop=5&amp;Compression=85&amp;FillCanvas=true&amp;DoNotUpscale=false&amp;image={{image}}" 303 @if (secondaryImage) { <text> 304 {{#if secondaryImage}} 305 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 306 {{/if}} 307 </text> } 308 alt="{{name}}" /> 309 {{#StickersContainers}} 310 {{>StickersContainer}} 311 {{/StickersContainers}} 312 @if (showFavoriteButton) 313 { 314 <div class="favorites favorites--for-grid-view u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 315 {{#Favorite}} 316 {{>FavoriteTemplate}} 317 {{/Favorite}} 318 </div> 319 } 320 </div> 321 322 <div class="grid__cell product-list__grid-item__price-info {{shortGridInfo}} dw-mod"> 323 <h2 class="u-condensed-text builder__content__card__header">{{name}}</h2> 324 <div class="builder__content__card__description">{{{description}}}</div> 325 326 @if (showPrice && !onlyPreview) 327 { 328 if (pointShopOnly) 329 { 330 <text> 331 {{#if havePointPrice}} 332 <div class="price price--product-list dw-mod">{{points}} @Translate("points")</div> 333 {{else}} 334 @Translate("Not available") 335 {{/if}} 336 </text> 337 } 338 else 339 { 340 <div class="price price--product-list dw-mod">{{price}}</div> 341 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 342 if (showVATPrice) 343 { 344 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 345 @if (isPricesWithVATEnabled) 346 { 347 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 348 } 349 else 350 { 351 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 352 } 353 </div> 354 } 355 } 356 } 357 <input type="hidden" value="{{unitId}}" name="Unit{{id}}" id="Unit_{{id}}" /> 358 <input type="hidden" value="{{variantid}}" name="VariantID{{id}}" id="Variant_{{id}}" /> 359 </div> 360 361 <div class="product-list__grid-item__footer @footerClasses dw-mod"> 362 <div class="u-ta-center u-inline-block u-full-width"> 363 <div class="buttons-collection {{hideBuyOptions}}"> 364 <button type="button" id="CartButton_{{id}}" class="js-cart-btn btn btn--secondary builder__content__btn dw-mod builder__content__btn--color-change--green u-full-width builder__mobile__btn {{disabledBuyButton}}" name="submit" 365 onclick="Cart.AddToCart(event, { 366 id: '{{productId}}', 367 variantId: '{{variantid}}', 368 unitId: '{{unitId}}', 369 quantity: document.getElementById('Quantity_{{id}}').value, 370 productInfo: {{productInfo}} 371 }); {{facebookPixelAction}}" {{disabledBuyButton}}> 372 <span class="u-hidden-xs u-hidden-xxs"> @cartButtonText</span> 373 </button> 374 <input type="hidden" class="u-w80px u-pull--right use-btn-primary-height" id="Quantity_{{id}}" name="Quantity{{id}}" value="1" min="1"> 375 <input type="hidden" value="{{unitId}}" name="Unit{{id}}" id="Unit_{{id}}" /> 376 </div> 377 </div> 378 379 @if (!onlyPreview && showStock) 380 { 381 <div class="u-margin-top"> 382 <div><span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> {{stockText}}</div> 383 <div> 384 {{#if deliveryText}} 385 {{deliveryText}} 386 {{else}} 387 - 388 {{/if}} 389 </div> 390 </div> 391 } 392 393 @if (showStaticVariants) 394 { 395 <text> 396 {{#Variants}} 397 {{>StaticVariantsTemplate}} 398 {{/Variants}} 399 400 {{#ifCond variantGroupsCount '>' 1}} 401 <div class="static-variant"> 402 @Translate("More options available") 403 </div> 404 {{/ifCond}} 405 406 {{#ifCond variantGroupsCount '==' 0}} 407 <div class="static-variant"></div> 408 {{/ifCond}} 409 </text> 410 } 411 412 @if (showAddToDownloadButton && Pageview.User != null) 413 { 414 <button type="button" class="btn btn--secondary u-no-margin u-margin-top btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 415 <i class="fas fa-plus js-button-icon"></i> 416 <span class="js-button-text">@Translate(viewMoreText)</span> 417 </button> 418 } 419 </div> 420 {{/.}} 421 </script> 422 } 423 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 424 @using Dynamicweb.Core 425 @using System 426 @using System.Web 427 @using System.Collections.Generic 428 @using Dynamicweb.Rapido.Blocks 429 430 @{ 431 BlocksPage productListPromotionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 432 433 Block productListPromotions = new Block 434 { 435 Id = "Promotions", 436 SortId = 10, 437 Template = RenderProductListPromotions() 438 }; 439 productListPromotionsBlocksPage.Add("PageContainer", productListPromotions); 440 } 441 442 @helper RenderProductListPromotions() 443 { 444 @*This is part of a script template *@ 445 446 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 447 bool isFavoriteList = !string.IsNullOrEmpty(listId); 448 449 if (!isFavoriteList) 450 { 451 switch (Pageview.AreaSettings.GetItem("ProductList").GetList("PromotionBlockDesign").SelectedValue) 452 { 453 case "OnlyText": 454 <article class="grid__col-12 u-margin-bottom"> 455 <h1>{{groupName}}</h1> 456 {{{groupDescription}}} 457 </article> 458 break; 459 case "TextAndImage": 460 <article class="grid__col-12 u-margin-bottom"> 461 <div class="grid grid--bleed"> 462 <div class="grid__col-md-6"> 463 <h1>{{groupName}}</h1> 464 {{{groupDescription}}} 465 </div> 466 {{#ifCond groupPromotionImage "!==" ""}} 467 <div class="grid__col-md-6"> 468 <img src="/Admin/Public/GetImage.ashx?width=600&crop=5&Compression=75&DoNotUpscale=true&image={{groupPromotionImage}}" alt="{{groupName}}" class="background-image__cover" /> 469 </div> 470 {{/ifCond}} 471 </div> 472 </article> 473 break; 474 case "Banner": 475 <text> 476 {{#ifCond groupPromotionImage "!==" ""}} 477 <article class="grid__col-12 u-margin-bottom"> 478 <div class="u-color-light grid center-container center-container--with-background-image u-padding" style="background-image:url('{{groupPromotionImage}}'); background-size: cover;"> 479 <div class="grid__col-12 u-middle"> 480 <div class="grid__cell"> 481 {{{groupDescription}}} 482 </div> 483 </div> 484 </div> 485 </article> 486 {{/ifCond}} 487 </text> 488 break; 489 } 490 } 491 } 492 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 493 @using Dynamicweb.Core 494 @using System 495 @using System.Web 496 @using System.Collections.Generic 497 @using Dynamicweb.Rapido.Blocks 498 499 @{ 500 BlocksPage productListMenuBlocksPage = BlocksPage.GetBlockPage("ProductList"); 501 502 if (Pageview.Page.PropertyItem["LeftMenu"] != null && Converter.ToString(Pageview.Page.PropertyItem["LeftMenu"]) == "True" && Pageview.Page.NavigationSettings != null && Pageview.Page.NavigationSettings.UseEcomGroups) { 503 Block productListMenuBlock = new Block 504 { 505 Id = "Menu", 506 SortId = 20, 507 Template = RenderProductListMenu() 508 }; 509 510 productListMenuBlocksPage.Add("Navigation", productListMenuBlock); 511 } 512 } 513 514 @helper RenderProductListMenu() 515 { 516 var navigationMarkup = RenderNavigation(new 517 { 518 id = "leftnav", 519 cssclass = "dwnavigation", 520 startLevel = 1, 521 endlevel = 5, 522 template = "LeftNavigation.xslt", 523 mode = "ecom" 524 }); 525 526 <h2 class="u-margin-bottom">@Translate("Product categories")</h2> 527 528 <div class="u-padding-bottom--lg"> 529 @navigationMarkup 530 </div> 531 } 532 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 533 @using Dynamicweb.Core 534 @using System 535 @using System.Web 536 @using System.Collections.Generic 537 @using Dynamicweb.Rapido.Blocks 538 539 @{ 540 BlocksPage productListBottomSnippetsPage = BlocksPage.GetBlockPage("ProductList"); 541 542 Block productListStickers = new Block 543 { 544 Id = "Stickers", 545 SortId = 10, 546 Template = RenderStickersTemplates() 547 }; 548 productListBottomSnippetsPage.Add("BottomSnippets", productListStickers); 549 550 Block productListUnits = new Block 551 { 552 Id = "Units", 553 SortId = 20, 554 Template = RenderUnitTemplates() 555 }; 556 productListBottomSnippetsPage.Add("BottomSnippets", productListUnits); 557 558 Block productListVariants = new Block 559 { 560 Id = "Variants", 561 SortId = 30, 562 Template = RenderVariantTemplates() 563 }; 564 productListBottomSnippetsPage.Add("BottomSnippets", productListVariants); 565 566 Block productListFavorites = new Block 567 { 568 Id = "Favorites", 569 SortId = 40, 570 Template = RenderFavoritesTemplates() 571 }; 572 productListBottomSnippetsPage.Add("BottomSnippets", productListFavorites); 573 574 Block productListPreRender = new Block 575 { 576 Id = "PreRenders", 577 SortId = 50, 578 Template = RenderPreRenderTemplates() 579 }; 580 productListBottomSnippetsPage.Add("BottomSnippets", productListPreRender); 581 582 Block productListInitializers = new Block 583 { 584 Id = "Initializers", 585 SortId = 60, 586 Template = RenderInitializers() 587 }; 588 productListBottomSnippetsPage.Add("BottomSnippets", productListInitializers); 589 } 590 591 @helper RenderStickersTemplates() { 592 <script id="StickersContainer" type="text/x-template"> 593 <div class="stickers-container stickers-container--{{position}} dw-mod"> 594 {{#Stickers}} 595 {{>Sticker}} 596 {{/Stickers}} 597 </div> 598 </script> 599 600 <script id="Sticker" type="text/x-template"> 601 <div class="stickers-container__tag {{className}} dw-mod">{{text}}</div> 602 </script> 603 604 <script id="MiniSticker" type="text/x-template"> 605 <div class="stickers-container__tag stickers-container__tag--micro {{className}} dw-mod">{{text}}</div> 606 </script> 607 } 608 609 @helper RenderUnitTemplates() { 610 <script id="UnitOption" type="text/x-template"> 611 <div class="dropdown__item dw-mod" onclick="HandlebarsBolt.UpdateContent('Product{{id}}', '{{link}}&feed=true&UnitID={{value}}&rid={{id}}')">{{name}}</div> 612 </script> 613 } 614 615 @helper RenderVariantTemplates() { 616 <script id="VariantsTemplate" type="text/x-template"> 617 {{#.}} 618 <div> 619 <div class="u-bold">{{name}}</div> 620 <div> 621 {{#VariantOptions}} 622 {{>VariantOption}} 623 {{/VariantOptions}} 624 </div> 625 </div> 626 {{/.}} 627 </script> 628 629 <script id="VariantOption" type="text/x-template"> 630 {{#if color}} 631 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--colorbox u-margin-right {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} style="background-color: {{color}}"></button> 632 {{else}} 633 {{#if image}} 634 <img data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" src="{{image}}" onclick="MatchVariants.SelectThis(event)" alt="{{name}}" title="{{name}}" class="btn btn--tag {{selected}} js-variant-option" data-check="{{selected}}" /> 635 {{else}} 636 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}}>{{name}}</button> 637 {{/if}} 638 {{/if}} 639 </script> 640 641 <script id="StaticVariantsTemplate" type="text/x-template"> 642 {{#.}} 643 {{#if isFirstGroup}} 644 <div> 645 {{#VariantOptions}} 646 {{>StaticVariantOption}} 647 {{/VariantOptions}} 648 </div> 649 {{/if}} 650 {{/.}} 651 </script> 652 653 <script id="StaticVariantOption" type="text/x-template"> 654 {{#if color}} 655 <div class="static-variant static-variant--color dw-mod" style="background-color: {{color}}" title="{{name}}"></div> 656 {{else}} 657 <div class="static-variant dw-mod">{{name}} </div> 658 {{/if}} 659 </script> 660 661 <script id="VariantOptionImage" type="text/x-template"> 662 <img data-variant-id="{{variantId}}" data-friends="{{friendsList}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" src="/Admin/Public/GetImage.ashx?width=100&amp;height=50&amp;crop=5&amp;Compression=75&amp;image=/Images/{{image}}" alt="{{name}}" title="{{name}}" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} /> 663 </script> 664 } 665 666 @helper RenderFavoritesTemplates() { 667 <script id="FavoriteTemplate" type="text/x-template"> 668 <div class="favorites-list u-ta-left"> 669 <label for="FavoriteTrigger_{{id}}" class="u-no-margin js-favorite-btn"><i class="{{favoriteIcon}} fa-1_5x"></i></label> 670 <input type="checkbox" id="FavoriteTrigger_{{id}}" class="dropdown-trigger" /> 671 <div class="dropdown dropdown--absolute-position"> 672 <div class="dropdown__content dropdown__content--show-left dropdown__content--padding u-w220px dw-mod"> 673 <ul class="list list--clean dw-mod"> 674 {{#FavoriteLists}} 675 {{>FavoriteListItem}} 676 {{/FavoriteLists}} 677 </ul> 678 </div> 679 <label class="dropdown-trigger-off" for="FavoriteTrigger_{{id}}"></label> 680 </div> 681 </div> 682 </script> 683 684 <script id="FavoriteListItem" type="text/x-template"> 685 <li> 686 <a href="{{link}}" class="list__link u-no-underline dw-mod" onclick="Scroll.SavePosition(event); {{facebookPixelAction}}"><i class="{{favoriteIcon}}"></i> {{name}}</a> 687 </li> 688 </script> 689 } 690 691 @helper RenderPreRenderTemplates() { 692 string facetsViewMode = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 693 694 <script id="ProductPreRenderContainer" type="text/x-template"> 695 @if (facetsViewMode == "left" && Pageview.Device.ToString() != "Mobile") 696 { 697 <div class="grid__col-3"> 698 <div class="pre-render-element pre-render-element--xs"></div> 699 <div class="pre-render-element pre-render-element--md"></div> 700 <div class="pre-render-element pre-render-element--md"></div> 701 <div class="pre-render-element pre-render-element--md"></div> 702 </div> 703 } 704 <div class="grid__col-auto"> 705 <div class="pre-render-element pre-render-element--xs"></div> 706 <div class="pre-render-element pre-render-element--lg"></div> 707 <div class="pre-render-element pre-render-element--lg"></div> 708 <div class="pre-render-element pre-render-element--lg"></div> 709 <div class="pre-render-element pre-render-element--lg"></div> 710 </div> 711 </script> 712 } 713 714 @helper RenderInitializers() { 715 <script> 716 document.addEventListener("DOMContentLoaded", function (event) { 717 document.getElementById("productList").addEventListener('contentLoaded', function (e) { 718 if (getTarget(e).id === "productList") { 719 Search.Init(); 720 Facets.Init("selectedFacets", "productList"); 721 } 722 }, false); 723 }); 724 </script> 725 } 726 727 @if (File.Exists(HttpContext.Current.Server.MapPath("/Files/Templates/Designs/Rapido/eCom/ProductList/Blocks/Custom__Blocks.cshtml"))) 728 { 729 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 730 @using System 731 @using Dynamicweb.Ecommerce.Products; 732 733 @{ 734 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("ProductList"); 735 BlocksPage masterBlocksPage = BlocksPage.GetBlockPage("Master"); 736 737 Block freeReturns = new Block 738 { 739 Id = "freeReturns", 740 SortId = 99, 741 Template = RenderFreeReturns() 742 }; 743 customBlocksPage.Add("PageContainer", freeReturns); 744 } 745 746 @helper RenderFreeReturns() 747 { 748 int optionsPageId = GetPageIdByNavigationTag("OptionsPage"); 749 int attachmentsPageId = GetPageIdByNavigationTag("AttachmentsPage"); 750 int documentsPageId = GetPageIdByNavigationTag("DocumentsPage"); 751 int cartPageId = GetPageIdByNavigationTag("CartPage"); 752 753 int currentPage = Convert.ToInt32(GetGlobalValue("Global:Page.ID")); 754 string nextPage = currentPage.ToString(); 755 756 string modelId = Dynamicweb.Context.Current.Request.QueryString["Model"]; 757 758 bool existingProduct = (Dynamicweb.Context.Current.Request.QueryString["Existing"] != null) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString["Existing"].ToString().ToLower()) : false; 759 760 string nextPageText = Translate("Continue"); 761 762 if (currentPage == attachmentsPageId) 763 { 764 if (!existingProduct) 765 { 766 if (Pageview.User == null) 767 { 768 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 769 nextPageText = Translate("Generate proposal - enduser"); 770 } 771 else 772 { 773 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 774 nextPageText = Translate("Select documents"); 775 } 776 } 777 else 778 { 779 if (Pageview.User == null) 780 { 781 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 782 nextPageText = Translate("Generate proposal - enduser"); 783 } 784 else 785 { 786 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 787 nextPageText = Translate("Select documents"); 788 } 789 } 790 } 791 792 if (currentPage == optionsPageId) 793 { 794 if (Pageview.User != null) 795 { 796 if (!existingProduct) 797 { 798 nextPage = attachmentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 799 nextPageText = Translate("Select tools"); 800 } 801 else 802 { 803 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 804 nextPageText = Translate("Select documents"); 805 } 806 } 807 else 808 { 809 if (existingProduct != false) 810 { 811 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 812 nextPageText = Translate("Generate proposal - enduser"); 813 } 814 else 815 { 816 nextPage = attachmentsPageId.ToString() + "&Model=" + modelId + "&Existing=False"; 817 nextPageText = Translate("Select tools"); 818 } 819 } 820 } 821 if (currentPage == documentsPageId) 822 { 823 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 824 if (Pageview.User == null) 825 { 826 nextPageText = Translate("Generate proposal - enduser"); 827 } 828 else 829 { 830 nextPageText = Translate("Generate proposal - dealer"); 831 } 832 } 833 834 <div class="grid__col-4 align-right"> 835 <div class="builder__cart"> 836 @{ 837 Product product = new ProductService().GetProductByNumber(modelId, true); 838 839 if (product != null) 840 { 841 <h2 class="builder__header--fontsize-28 u-mb-0px">@product.Name</h2> 842 } 843 844 <div>&nbsp;</div> 845 <div id="egholmCart"></div> 846 } 847 <div class="grid__col-12"></div> 848 <div class="grid__col-12"> 849 <a href="/Default.aspx?ID=@nextPage" class="btn btn--secondary builder__content__btn builder__content__btn--orange builder__content__btn--width100 u-mt-20px">@nextPageText &raquo;</a> 850 </div> 851 </div> 852 <div class="grid__col-12"> 853 @if ((currentPage == attachmentsPageId || currentPage == documentsPageId) && !existingProduct) 854 { 855 <a href="Default.aspx?ID=@optionsPageId&Model=@modelId&Existing=@existingProduct.ToString()" class="btn btn--secondary builder__content__btn builder__content__btn--grey u-mt-20px">@Translate("Back to Accessories")</a> 856 } 857 @if (currentPage == documentsPageId && !existingProduct) 858 { 859 <a href="Default.aspx?ID=@attachmentsPageId&Model=@modelId&Existing=@existingProduct.ToString()" class="btn btn--secondary builder__content__btn builder__content__btn--grey u-mt-10px">@Translate("Back to Attachments")</a> 860 } 861 <a href="#" onclick="Cart.EmptyCart(event); return false; window.location = '/configurator';" id="restart" name="restart" class="btn btn--secondary builder__content__btn builder__content__btn--grey u-mt-10px">@Translate("Clear and restart")</a> 862 </div> 863 </div> 864 }</text> 865 } 866 867 @if (productListNavigation.BlocksList.Count < 1) 868 { 869 productListNavigation.Design.RenderType = RenderType.Hide; 870 } 871 872 <form name="multiForm" id="multiForm" method="post"> 873 <input type="hidden" name="CartCmd" id="attachmentCartCmd" value="addMulti" /> 874 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 875 @RenderBlockList(productListPage.BlocksRoot.BlocksList) 876 </form> 877 878 @helper RenderPageContainer() 879 { 880 @RenderPageTop() 881 882 List<Block> subBlocks = this.productListPage.GetBlockListById("PageContainer").OrderBy(item => item.SortId).ToList(); 883 884 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 885 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 886 bool isFavoriteList = !string.IsNullOrEmpty(listId); 887 string feedFullUrl = pageUrl + "&feed=true"; 888 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 889 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "" : ""; 890 891 <div class="grid grid--align-content-start @smallDeviceCss js-handlebars-root" id="productList" data-template="ProductContainer" data-pre-render-template="ProductPreRenderContainer" data-json-feed="@feedFullUrl" data-preloader="overlay"></div> 892 893 <script id="ProductContainer" type="text/x-template"> 894 {{#each .}} 895 @RenderBlockList(subBlocks) 896 {{else}} 897 <div class="grid__col-12"> 898 <h2 class="u-ta-center">@Translate("Your search gave 0 results")</h2> 899 </div> 900 {{/each}} 901 </script> 902 } 903 904 @helper RenderPageTop() { 905 string modelId = Dynamicweb.Context.Current.Request.QueryString["Model"]; 906 Product product = new ProductService().GetProductByNumber(modelId, true); 907 908 int attachmentsPageId = GetPageIdByNavigationTag("AttachmentsPage"); 909 int accessoriesPageId = GetPageIdByNavigationTag("OptionsPage"); 910 int documentsPageId = GetPageIdByNavigationTag("DocumentsPage"); 911 int currentPage = Convert.ToInt32(GetGlobalValue("Global:Page.ID")); 912 913 string heading = string.Empty; 914 string paragraph = string.Empty; 915 string clientString = string.Empty; 916 917 if(currentPage == attachmentsPageId) 918 { 919 paragraph = Translate("Now select your attachments for"); 920 } 921 if (currentPage == accessoriesPageId) 922 { 923 paragraph = Translate("Now select your accessories for"); 924 } 925 if (currentPage == documentsPageId) 926 { 927 paragraph = Translate("Now select your documents for"); 928 } 929 if(Pageview.User != null) 930 { 931 clientString = Translate(" for client"); 932 } 933 934 <h2>@Translate("Building") @product.Name @clientString</h2> 935 <h4>@paragraph @product.Name</h4> 936 } 937 938 @helper RenderProductList() 939 { 940 @*This is part of a script template *@ 941 942 List<Block> subBlocks = productListPage.GetBlockListById("ProductList").OrderBy(item => item.SortId).ToList(); 943 944 string pageId = GetGlobalValue("Global:Page.ID"); 945 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 946 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 947 bool isFavoriteList = !string.IsNullOrEmpty(listId); 948 string feedFullUrl = pageUrl + "&feed=true"; 949 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 950 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 951 952 <div class="grid__col-auto @smallDeviceCss u-no-padding"> 953 @if (isFavoriteList) 954 { 955 string searchPlaceholder = Translate("Search favorite products", "Search favorite products"); 956 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 957 958 <div class="grid__cell"> 959 <div class="u-pull--left"> 960 <h2 class="u-no-margin"><i class="{{headerIcon}}"></i>{{header}}</h2> 961 </div> 962 <div class="grid__col--bleed grid__col-6 u-pull--right"> 963 <div class="u-margin-bottom"> 964 <div class="typeahead u-color-inherit js-typeahead" data-page-size="10" id="FavoritesSearch" data-list-id="@listId" data-search-feed-id="@pageId&feed=true" data-result-page-id="@pageId"> 965 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 966 <ul class="dropdown dropdown--absolute-position u-full-width js-handlebars-root js-typeahead-search-content u-min-w220px u-full-width dw-mod" id="FavoritesSearchContent" data-template="SearchProductsTemplate" data-json-feed="@feedFullUrl&ListID=@listId" data-init-onload="false" data-preloader="minimal"></ul> 967 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="fas fa-search"></i></button> 968 </div> 969 </div> 970 </div> 971 </div> 972 } 973 974 <div class="grid__cell"> 975 @RenderBlockList(subBlocks) 976 </div> 977 </div> 978 } 979