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_1ccbb01d52ff4165a741d9986e8d04f0.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 946
   at CompiledRazorTemplates.Dynamic.RazorEngine_1ccbb01d52ff4165a741d9986e8d04f0.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 890
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_1ccbb01d52ff4165a741d9986e8d04f0.<>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_1ccbb01d52ff4165a741d9986e8d04f0.<>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_1ccbb01d52ff4165a741d9986e8d04f0.Execute() in D:\Dynamicweb.net\Solutions\FactorAdman\egholm2019.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\Productlist\ConfiguratorRender.cshtml:line 885
   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 = 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 b-lazy @*configurator-image*@" 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" data-prodid="{{productId}}" data-variantid="{{variantid}}" data-unitid="{{unitId}}" data-prodinfo="{{productInfo}}" data-quantity="1" data-id="{{id}}" style="min-height: 42px !important;" 365 onclick="checkProductQuantity(event) {{disabledBuyButton}}"> 366 @cartButtonText 367 </button> 368 <input type="hidden" class="u-w80px u-pull--right use-btn-primary-height" id="Quantity_{{id}}" name="Quantity{{id}}" value="1" min="1"> 369 <input type="hidden" value="{{unitId}}" name="Unit{{id}}" id="Unit_{{id}}" /> 370 </div> 371 </div> 372 373 @if (!onlyPreview && showStock) 374 { 375 <div class="u-margin-top"> 376 <div><span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> {{stockText}}</div> 377 <div> 378 {{#if deliveryText}} 379 {{deliveryText}} 380 {{else}} 381 - 382 {{/if}} 383 </div> 384 </div> 385 } 386 387 @if (showStaticVariants) 388 { 389 <text> 390 {{#Variants}} 391 {{>StaticVariantsTemplate}} 392 {{/Variants}} 393 394 {{#ifCond variantGroupsCount '>' 1}} 395 <div class="static-variant"> 396 @Translate("More options available") 397 </div> 398 {{/ifCond}} 399 400 {{#ifCond variantGroupsCount '==' 0}} 401 <div class="static-variant"></div> 402 {{/ifCond}} 403 </text> 404 } 405 406 @if (showAddToDownloadButton && Pageview.User != null) 407 { 408 <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}}"> 409 <i class="fas fa-plus js-button-icon"></i> 410 <span class="js-button-text">@Translate(viewMoreText)</span> 411 </button> 412 } 413 </div> 414 {{/.}} 415 </script> 416 } 417 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 418 @using Dynamicweb.Core 419 @using System 420 @using System.Web 421 @using System.Collections.Generic 422 @using Dynamicweb.Rapido.Blocks 423 424 @{ 425 BlocksPage productListPromotionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 426 427 Block productListPromotions = new Block 428 { 429 Id = "Promotions", 430 SortId = 10, 431 Template = RenderProductListPromotions() 432 }; 433 productListPromotionsBlocksPage.Add("PageContainer", productListPromotions); 434 } 435 436 @helper RenderProductListPromotions() 437 { 438 @*This is part of a script template *@ 439 440 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 441 bool isFavoriteList = !string.IsNullOrEmpty(listId); 442 443 if (!isFavoriteList) 444 { 445 switch (Pageview.AreaSettings.GetItem("ProductList").GetList("PromotionBlockDesign").SelectedValue) 446 { 447 case "OnlyText": 448 <article class="grid__col-12 u-margin-bottom"> 449 <h1>{{groupName}}</h1> 450 {{{groupDescription}}} 451 </article> 452 break; 453 case "TextAndImage": 454 <article class="grid__col-12 u-margin-bottom"> 455 <div class="grid grid--bleed"> 456 <div class="grid__col-md-6"> 457 <h1>{{groupName}}</h1> 458 {{{groupDescription}}} 459 </div> 460 {{#ifCond groupPromotionImage "!==" ""}} 461 <div class="grid__col-md-6"> 462 <img src="/Admin/Public/GetImage.ashx?width=600&crop=5&Compression=75&DoNotUpscale=true&image={{groupPromotionImage}}" alt="{{groupName}}" class="background-image__cover" /> 463 </div> 464 {{/ifCond}} 465 </div> 466 </article> 467 break; 468 case "Banner": 469 <text> 470 {{#ifCond groupPromotionImage "!==" ""}} 471 <article class="grid__col-12 u-margin-bottom"> 472 <div class="u-color-light grid center-container center-container--with-background-image u-padding" style="background-image:url('{{groupPromotionImage}}'); background-size: cover;"> 473 <div class="grid__col-12 u-middle"> 474 <div class="grid__cell"> 475 {{{groupDescription}}} 476 </div> 477 </div> 478 </div> 479 </article> 480 {{/ifCond}} 481 </text> 482 break; 483 } 484 } 485 } 486 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 487 @using Dynamicweb.Core 488 @using System 489 @using System.Web 490 @using System.Collections.Generic 491 @using Dynamicweb.Rapido.Blocks 492 493 @{ 494 BlocksPage productListMenuBlocksPage = BlocksPage.GetBlockPage("ProductList"); 495 496 if (Pageview.Page.PropertyItem["LeftMenu"] != null && Converter.ToString(Pageview.Page.PropertyItem["LeftMenu"]) == "True" && Pageview.Page.NavigationSettings != null && Pageview.Page.NavigationSettings.UseEcomGroups) { 497 Block productListMenuBlock = new Block 498 { 499 Id = "Menu", 500 SortId = 20, 501 Template = RenderProductListMenu() 502 }; 503 504 productListMenuBlocksPage.Add("Navigation", productListMenuBlock); 505 } 506 } 507 508 @helper RenderProductListMenu() 509 { 510 var navigationMarkup = RenderNavigation(new 511 { 512 id = "leftnav", 513 cssclass = "dwnavigation", 514 startLevel = 1, 515 endlevel = 5, 516 template = "LeftNavigation.xslt", 517 mode = "ecom" 518 }); 519 520 <h2 class="u-margin-bottom">@Translate("Product categories")</h2> 521 522 <div class="u-padding-bottom--lg"> 523 @navigationMarkup 524 </div> 525 } 526 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 527 @using Dynamicweb.Core 528 @using System 529 @using System.Web 530 @using System.Collections.Generic 531 @using Dynamicweb.Rapido.Blocks 532 533 @{ 534 BlocksPage productListBottomSnippetsPage = BlocksPage.GetBlockPage("ProductList"); 535 536 Block productListStickers = new Block 537 { 538 Id = "Stickers", 539 SortId = 10, 540 Template = RenderStickersTemplates() 541 }; 542 productListBottomSnippetsPage.Add("BottomSnippets", productListStickers); 543 544 Block productListUnits = new Block 545 { 546 Id = "Units", 547 SortId = 20, 548 Template = RenderUnitTemplates() 549 }; 550 productListBottomSnippetsPage.Add("BottomSnippets", productListUnits); 551 552 Block productListVariants = new Block 553 { 554 Id = "Variants", 555 SortId = 30, 556 Template = RenderVariantTemplates() 557 }; 558 productListBottomSnippetsPage.Add("BottomSnippets", productListVariants); 559 560 Block productListFavorites = new Block 561 { 562 Id = "Favorites", 563 SortId = 40, 564 Template = RenderFavoritesTemplates() 565 }; 566 productListBottomSnippetsPage.Add("BottomSnippets", productListFavorites); 567 568 Block productListPreRender = new Block 569 { 570 Id = "PreRenders", 571 SortId = 50, 572 Template = RenderPreRenderTemplates() 573 }; 574 productListBottomSnippetsPage.Add("BottomSnippets", productListPreRender); 575 576 Block productListInitializers = new Block 577 { 578 Id = "Initializers", 579 SortId = 60, 580 Template = RenderInitializers() 581 }; 582 productListBottomSnippetsPage.Add("BottomSnippets", productListInitializers); 583 } 584 585 @helper RenderStickersTemplates() { 586 <script id="StickersContainer" type="text/x-template"> 587 <div class="stickers-container stickers-container--{{position}} dw-mod"> 588 {{#Stickers}} 589 {{>Sticker}} 590 {{/Stickers}} 591 </div> 592 </script> 593 594 <script id="Sticker" type="text/x-template"> 595 <div class="stickers-container__tag {{className}} dw-mod">{{text}}</div> 596 </script> 597 598 <script id="MiniSticker" type="text/x-template"> 599 <div class="stickers-container__tag stickers-container__tag--micro {{className}} dw-mod">{{text}}</div> 600 </script> 601 } 602 603 @helper RenderUnitTemplates() { 604 <script id="UnitOption" type="text/x-template"> 605 <div class="dropdown__item dw-mod" onclick="HandlebarsBolt.UpdateContent('Product{{id}}', '{{link}}&feed=true&UnitID={{value}}&rid={{id}}')">{{name}}</div> 606 </script> 607 } 608 609 @helper RenderVariantTemplates() { 610 <script id="VariantsTemplate" type="text/x-template"> 611 {{#.}} 612 <div> 613 <div class="u-bold">{{name}}</div> 614 <div> 615 {{#VariantOptions}} 616 {{>VariantOption}} 617 {{/VariantOptions}} 618 </div> 619 </div> 620 {{/.}} 621 </script> 622 623 <script id="VariantOption" type="text/x-template"> 624 {{#if color}} 625 <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> 626 {{else}} 627 {{#if image}} 628 <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}}" /> 629 {{else}} 630 <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> 631 {{/if}} 632 {{/if}} 633 </script> 634 635 <script id="StaticVariantsTemplate" type="text/x-template"> 636 {{#.}} 637 {{#if isFirstGroup}} 638 <div> 639 {{#VariantOptions}} 640 {{>StaticVariantOption}} 641 {{/VariantOptions}} 642 </div> 643 {{/if}} 644 {{/.}} 645 </script> 646 647 <script id="StaticVariantOption" type="text/x-template"> 648 {{#if color}} 649 <div class="static-variant static-variant--color dw-mod" style="background-color: {{color}}" title="{{name}}"></div> 650 {{else}} 651 <div class="static-variant dw-mod">{{name}} </div> 652 {{/if}} 653 </script> 654 655 <script id="VariantOptionImage" type="text/x-template"> 656 <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}} /> 657 </script> 658 } 659 660 @helper RenderFavoritesTemplates() { 661 <script id="FavoriteTemplate" type="text/x-template"> 662 <div class="favorites-list u-ta-left"> 663 <label for="FavoriteTrigger_{{id}}" class="u-no-margin js-favorite-btn"><i class="{{favoriteIcon}} fa-1_5x"></i></label> 664 <input type="checkbox" id="FavoriteTrigger_{{id}}" class="dropdown-trigger" /> 665 <div class="dropdown dropdown--absolute-position"> 666 <div class="dropdown__content dropdown__content--show-left dropdown__content--padding u-w220px dw-mod"> 667 <ul class="list list--clean dw-mod"> 668 {{#FavoriteLists}} 669 {{>FavoriteListItem}} 670 {{/FavoriteLists}} 671 </ul> 672 </div> 673 <label class="dropdown-trigger-off" for="FavoriteTrigger_{{id}}"></label> 674 </div> 675 </div> 676 </script> 677 678 <script id="FavoriteListItem" type="text/x-template"> 679 <li> 680 <a href="{{link}}" class="list__link u-no-underline dw-mod" onclick="Scroll.SavePosition(event); {{facebookPixelAction}}"><i class="{{favoriteIcon}}"></i> {{name}}</a> 681 </li> 682 </script> 683 } 684 685 @helper RenderPreRenderTemplates() { 686 string facetsViewMode = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 687 688 <script id="ProductPreRenderContainer" type="text/x-template"> 689 @if (facetsViewMode == "left" && Pageview.Device.ToString() != "Mobile") 690 { 691 <div class="grid__col-3"> 692 <div class="pre-render-element pre-render-element--xs"></div> 693 <div class="pre-render-element pre-render-element--md"></div> 694 <div class="pre-render-element pre-render-element--md"></div> 695 <div class="pre-render-element pre-render-element--md"></div> 696 </div> 697 } 698 <div class="grid__col-auto"> 699 <div class="pre-render-element pre-render-element--xs"></div> 700 <div class="pre-render-element pre-render-element--lg"></div> 701 <div class="pre-render-element pre-render-element--lg"></div> 702 <div class="pre-render-element pre-render-element--lg"></div> 703 <div class="pre-render-element pre-render-element--lg"></div> 704 </div> 705 </script> 706 } 707 708 @helper RenderInitializers() { 709 <script> 710 document.addEventListener("DOMContentLoaded", function (event) { 711 document.getElementById("productList").addEventListener('contentLoaded', function (e) { 712 if (getTarget(e).id === "productList") { 713 Search.Init(); 714 Facets.Init("selectedFacets", "productList"); 715 } 716 }, false); 717 }); 718 </script> 719 } 720 721 @if (File.Exists(HttpContext.Current.Server.MapPath("/Files/Templates/Designs/Rapido/eCom/ProductList/Blocks/Custom__Blocks.cshtml"))) 722 { 723 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 724 @using System 725 @using Dynamicweb.Ecommerce.Products; 726 727 @{ 728 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("ProductList"); 729 BlocksPage masterBlocksPage = BlocksPage.GetBlockPage("Master"); 730 731 Block freeReturns = new Block 732 { 733 Id = "freeReturns", 734 SortId = 99, 735 Template = RenderFreeReturns() 736 }; 737 customBlocksPage.Add("PageContainer", freeReturns); 738 } 739 740 @helper RenderFreeReturns() 741 { 742 int optionsPageId = GetPageIdByNavigationTag("OptionsPage"); 743 int attachmentsPageId = GetPageIdByNavigationTag("AttachmentsPage"); 744 int documentsPageId = GetPageIdByNavigationTag("DocumentsPage"); 745 int cartPageId = GetPageIdByNavigationTag("CartPage"); 746 747 int currentPage = Convert.ToInt32(GetGlobalValue("Global:Page.ID")); 748 string nextPage = currentPage.ToString(); 749 750 string modelId = Dynamicweb.Context.Current.Request.QueryString["Model"]; 751 752 bool existingProduct = (Dynamicweb.Context.Current.Request.QueryString["Existing"] != null) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString["Existing"].ToString().ToLower()) : false; 753 754 string nextPageText = Translate("Continue"); 755 756 if (currentPage == attachmentsPageId) 757 { 758 if (!existingProduct) 759 { 760 if (Pageview.User == null) 761 { 762 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 763 nextPageText = Translate("Generate proposal - enduser"); 764 } 765 else 766 { 767 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 768 nextPageText = Translate("Select documents"); 769 } 770 } 771 else 772 { 773 if (Pageview.User == null) 774 { 775 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 776 nextPageText = Translate("Generate proposal - enduser"); 777 } 778 else 779 { 780 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 781 nextPageText = Translate("Select documents"); 782 } 783 } 784 } 785 786 if (currentPage == optionsPageId) 787 { 788 if (Pageview.User != null) 789 { 790 if (!existingProduct) 791 { 792 nextPage = attachmentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 793 nextPageText = Translate("Select tools"); 794 } 795 else 796 { 797 nextPage = documentsPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 798 nextPageText = Translate("Select documents"); 799 } 800 } 801 else 802 { 803 if (existingProduct != false) 804 { 805 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 806 nextPageText = Translate("Generate proposal - enduser"); 807 } 808 else 809 { 810 nextPage = attachmentsPageId.ToString() + "&Model=" + modelId + "&Existing=False"; 811 nextPageText = Translate("Select tools"); 812 } 813 } 814 } 815 if (currentPage == documentsPageId) 816 { 817 nextPage = cartPageId.ToString() + "&Model=" + modelId + "&Existing=" + existingProduct; 818 if (Pageview.User == null) 819 { 820 nextPageText = Translate("Generate proposal - enduser"); 821 } 822 else 823 { 824 nextPageText = Translate("Generate proposal - dealer"); 825 } 826 } 827 828 <div class="grid__col-lg-4 align-right"> 829 <div class="builder__cart"> 830 @{ 831 Product product = new ProductService().GetProductByNumber(modelId, true); 832 833 if (product != null) 834 { 835 <h2 class="builder__header--fontsize-28 u-mb-0px">@product.Name</h2> 836 } 837 838 <div>&nbsp;</div> 839 <div id="egholmCart"></div> 840 <input value="@Translate("Cart_Remove", "Remove")" id="egholmCartRemoveTranslations" type="hidden" /> 841 @*KR 09222020*@ 842 <input value="@Translate("Total", "Total")" id="egholmCartTotalTranslations" type="hidden" /> 843 <input value="@Translate("Price without VAT", "Price without VAT")" id="egholmCartPriceWithoutVATTranslations" type="hidden" /> 844 @*\KR 09222020*@ 845 } 846 <div class="grid__col-12"></div> 847 <div class="grid__col-12"> 848 <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</a> 849 </div> 850 </div> 851 <div class="grid__col-12"> 852 @if ((currentPage == attachmentsPageId || currentPage == documentsPageId) && !existingProduct) 853 { 854 <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> 855 } 856 @if (currentPage == documentsPageId && !existingProduct) 857 { 858 <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> 859 } 860 <a href="/Default.aspx?ID=@GetPageIdByNavigationTag("CartPage")&cartcmd=emptycart&Redirect=@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("ConfiguratorPage"))" class="btn btn--secondary builder__content__btn builder__content__btn--grey u-mt-10px">@Translate("Clear and restart")</a> 861 862 <!-- 863 <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> 864 --> 865 866 </div> 867 </div> 868 }</text> 869 } 870 871 @if (productListNavigation.BlocksList.Count < 1) 872 { 873 productListNavigation.Design.RenderType = RenderType.Hide; 874 } 875 876 <input type="hidden" id="CartOrderlinesFeed" name="CartOrderlinesFeed" value="@GetPageIdByNavigationTag("CartOrderlinesFeed")" /> 877 <input type="hidden" id="OptionsPage" name="OptionsPage" value="@GetPageIdByNavigationTag("OptionsPage")"/> 878 <input type="hidden" id="DomainUrl" name="DomainUrl" value="@HttpContext.Current.Request.Url.ToString().Substring(0, HttpContext.Current.Request.Url.ToString().IndexOf("/Default.aspx"))"/> 879 <input type="hidden" id="ConfiguratorPath" name="ConfiguratorPath" value="@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("ConfiguratorPage"))"/> 880 <input type="hidden" id="alertTranslation" name="alertTranslation" value="@Translate("already_in_cart", "Already in the cart")" /> 881 <input type="hidden" id="emptyCartTranslation" name="emptyCartTranslation" value="@Translate("empty_configurator", "Your configurator is empty")" /> 882 <form name="multiForm" id="multiForm" method="post"> 883 <input type="hidden" name="CartCmd" id="attachmentCartCmd" value="addMulti" /> 884 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 885 @RenderBlockList(productListPage.BlocksRoot.BlocksList) 886 </form> 887 888 @helper RenderPageContainer() 889 { 890 @RenderPageTop() 891 892 List<Block> subBlocks = this.productListPage.GetBlockListById("PageContainer").OrderBy(item => item.SortId).ToList(); 893 894 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 895 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 896 bool isFavoriteList = !string.IsNullOrEmpty(listId); 897 string feedFullUrl = pageUrl + "&feed=true"; 898 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 899 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "" : ""; 900 901 <div class="grid grid--align-content-start @smallDeviceCss js-handlebars-root rearrangecart" id="productList" data-template="ProductContainer" data-pre-render-template="ProductPreRenderContainer" data-json-feed="@feedFullUrl" data-preloader="overlay"></div> 902 903 <script id="ProductContainer" type="text/x-template"> 904 {{#each .}} 905 @RenderBlockList(subBlocks) 906 {{else}} 907 <div class="grid__col-12"> 908 <h2 class="u-ta-center">@Translate("Your search gave 0 results")</h2> 909 </div> 910 {{/each}} 911 </script> 912 } 913 914 @helper RenderPageTop() { 915 string modelId = Dynamicweb.Context.Current.Request.QueryString["Model"]; 916 Product product = new ProductService().GetProductByNumber(modelId, true); 917 918 int attachmentsPageId = GetPageIdByNavigationTag("AttachmentsPage"); 919 int accessoriesPageId = GetPageIdByNavigationTag("OptionsPage"); 920 int documentsPageId = GetPageIdByNavigationTag("DocumentsPage"); 921 int currentPage = Convert.ToInt32(GetGlobalValue("Global:Page.ID")); 922 923 string heading = string.Empty; 924 string paragraph = string.Empty; 925 string clientString = string.Empty; 926 string paragraphText = string.Empty; 927 928 if(currentPage == attachmentsPageId) 929 { 930 paragraph = Translate("Now select your attachments for"); 931 } 932 if (currentPage == accessoriesPageId) 933 { 934 paragraph = Translate("Now select your accessories for"); 935 } 936 if (currentPage == documentsPageId) 937 { 938 paragraph = Translate("Now select your documents for"); 939 paragraphText = Translate("Document textarea"); 940 } 941 if(Pageview.User != null) 942 { 943 clientString = Translate(" for client"); 944 } 945 946 <h2>@Translate("Building") @product.Name @clientString</h2> 947 <h4>@paragraph @product.Name</h4> 948 if (!String.IsNullOrEmpty(paragraphText)) 949 { 950 <p>@paragraphText</p> 951 } 952 } 953 954 @helper RenderProductList() 955 { 956 @*This is part of a script template *@ 957 958 List<Block> subBlocks = productListPage.GetBlockListById("ProductList").OrderBy(item => item.SortId).ToList(); 959 960 string pageId = GetGlobalValue("Global:Page.ID"); 961 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 962 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 963 bool isFavoriteList = !string.IsNullOrEmpty(listId); 964 string feedFullUrl = pageUrl + "&feed=true"; 965 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 966 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 967 968 <div class="grid__col-lg-8 @smallDeviceCss u-no-padding"> 969 @if (isFavoriteList) 970 { 971 string searchPlaceholder = Translate("Search favorite products", "Search favorite products"); 972 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 973 974 <div class="grid__cell"> 975 <div class="u-pull--left"> 976 <h2 class="u-no-margin"><i class="{{headerIcon}}"></i>{{header}}</h2> 977 </div> 978 <div class="grid__col--bleed grid__col-6 u-pull--right"> 979 <div class="u-margin-bottom"> 980 <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"> 981 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 982 <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> 983 <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> 984 </div> 985 </div> 986 </div> 987 </div> 988 } 989 990 <div class="grid__cell"> 991 @RenderBlockList(subBlocks) 992 </div> 993 </div> 994 } 995