Error executing template "Designs/Rapido/eCom/Productlist/Custom__VirtualLaunchList.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_618d6a2b24a84426a95cd6bd5ecfea51.GetProductSorting() in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom\Productlist\Custom__VirtualLaunchList.cshtml:line 2424
   at CompiledRazorTemplates.Dynamic.RazorEngine_618d6a2b24a84426a95cd6bd5ecfea51.Execute() in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom\Productlist\Custom__VirtualLaunchList.cshtml:line 2434
   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.Core 3 @using Dynamicweb.Rapido.Blocks 4 @using Dynamicweb.Rapido.Blocks.Components.General 5 @using Dynamicweb.Content.Items.Metadata 6 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 7 @using System.Text.RegularExpressions 8 @using System.Collections.Generic 9 @using System.Reflection 10 @using System.Web 11 @using System.Web.UI.HtmlControls 12 @using Dynamicweb.Rapido.Blocks.Components 13 @using Dynamicweb.Rapido.Blocks.Components.Articles 14 @using Dynamicweb.Rapido.Blocks.Components.Documentation 15 @using Dynamicweb.Rapido.Blocks 16 17 18 @*--- START: Base block renderers ---*@ 19 20 @helper RenderBlockList(List<Block> blocks) 21 { 22 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 23 blocks = blocks.OrderBy(item => item.SortId).ToList(); 24 25 foreach (Block item in blocks) 26 { 27 if (debug) { 28 <!-- Block START: @item.Id --> 29 } 30 31 if (item.Design == null) 32 { 33 @RenderBlock(item) 34 } 35 else if (item.Design.RenderType == RenderType.None) { 36 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 37 38 <div class="@cssClass dw-mod"> 39 @RenderBlock(item) 40 </div> 41 } 42 else if (item.Design.RenderType != RenderType.Hide) 43 { 44 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 45 46 if (!item.SkipRenderBlocksList) { 47 if (item.Design.RenderType == RenderType.Row) 48 { 49 <div class="grid grid--align-content-start @cssClass dw-mod" id="[email protected]"> 50 @RenderBlock(item) 51 </div> 52 } 53 54 if (item.Design.RenderType == RenderType.Column) 55 { 56 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 57 string size = item.Design.Size ?? "12"; 58 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 59 60 <div class="[email protected] [email protected] grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="[email protected]"> 61 @RenderBlock(item) 62 </div> 63 } 64 65 if (item.Design.RenderType == RenderType.Table) 66 { 67 <table class="table @cssClass dw-mod" id="[email protected]"> 68 @RenderBlock(item) 69 </table> 70 } 71 72 if (item.Design.RenderType == RenderType.TableRow) 73 { 74 <tr class="@cssClass dw-mod" id="[email protected]"> 75 @RenderBlock(item) 76 </tr> 77 } 78 79 if (item.Design.RenderType == RenderType.TableColumn) 80 { 81 <td class="@cssClass dw-mod" id="[email protected]"> 82 @RenderBlock(item) 83 </td> 84 } 85 86 if (item.Design.RenderType == RenderType.CardHeader) 87 { 88 <div class="card-header @cssClass dw-mod"> 89 @RenderBlock(item) 90 </div> 91 } 92 93 if (item.Design.RenderType == RenderType.CardBody) 94 { 95 <div class="card @cssClass dw-mod"> 96 @RenderBlock(item) 97 </div> 98 } 99 100 if (item.Design.RenderType == RenderType.CardFooter) 101 { 102 <div class="card-footer @cssClass dw-mod"> 103 @RenderBlock(item) 104 </div> 105 } 106 } 107 else 108 { 109 @RenderBlock(item) 110 } 111 } 112 113 if (debug) { 114 <!-- Block END: @item.Id --> 115 } 116 } 117 } 118 119 @helper RenderBlock(Block item) 120 { 121 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 122 123 if (item.Template != null) 124 { 125 @BlocksPage.RenderTemplate(item.Template) 126 } 127 128 if (item.Component != null) 129 { 130 string customSufix = "Custom"; 131 string methodName = item.Component.HelperName; 132 133 ComponentBase[] methodParameters = new ComponentBase[1]; 134 methodParameters[0] = item.Component; 135 Type methodType = this.GetType(); 136 137 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 138 MethodInfo generalMethod = methodType.GetMethod(methodName); 139 140 try { 141 if (debug) { 142 <!-- Component: @methodName.Replace("Render", "") --> 143 } 144 @customMethod.Invoke(this, methodParameters).ToString(); 145 } catch { 146 try { 147 @generalMethod.Invoke(this, methodParameters).ToString(); 148 } catch(Exception ex) { 149 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 150 } 151 } 152 } 153 154 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 155 { 156 @RenderBlockList(item.BlocksList) 157 } 158 } 159 160 @*--- END: Base block renderers ---*@ 161 162 @using Dynamicweb.Rapido.Blocks.Components 163 @using Dynamicweb.Rapido.Blocks.Components.General 164 @using Dynamicweb.Rapido.Blocks 165 @using System.IO 166 167 @* Required *@ 168 @using Dynamicweb.Rapido.Blocks.Components 169 @using Dynamicweb.Rapido.Blocks.Components.General 170 @using Dynamicweb.Rapido.Blocks 171 172 173 @helper Render(ComponentBase component) 174 { 175 if (component != null) 176 { 177 @component.Render(this) 178 } 179 } 180 181 182 @* Components *@ 183 @using System.Reflection 184 @using Dynamicweb.Rapido.Blocks.Components.General 185 186 187 @* Component *@ 188 189 @helper RenderIcon(Icon settings) 190 { 191 if (settings != null) 192 { 193 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 194 195 if (settings.Name != null) 196 { 197 if (string.IsNullOrEmpty(settings.Label)) 198 { 199 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 200 } 201 else 202 { 203 if (settings.LabelPosition == IconLabelPosition.Before) 204 { 205 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 206 } 207 else 208 { 209 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 210 } 211 } 212 } 213 else if (!string.IsNullOrEmpty(settings.Label)) 214 { 215 @settings.Label 216 } 217 } 218 } 219 @using System.Reflection 220 @using Dynamicweb.Rapido.Blocks.Components.General 221 @using Dynamicweb.Rapido.Blocks.Components 222 @using Dynamicweb.Core 223 224 @* Component *@ 225 226 @helper RenderButton(Button settings) 227 { 228 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 229 { 230 Dictionary<string, string> attributes = new Dictionary<string, string>(); 231 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 232 if (settings.Disabled) { 233 attributes.Add("disabled", "true"); 234 classList.Add("disabled"); 235 } 236 237 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 238 { 239 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 240 @RenderConfirmDialog(settings); 241 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 242 } 243 244 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 245 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 246 if (!string.IsNullOrEmpty(settings.AltText)) 247 { 248 attributes.Add("aria-label", settings.AltText); 249 } 250 251 var onClickEvents = new List<string>(); 252 if (!string.IsNullOrEmpty(settings.OnClick)) 253 { 254 onClickEvents.Add(settings.OnClick); 255 } 256 if (!string.IsNullOrEmpty(settings.Href)) 257 { 258 onClickEvents.Add("location.href='" + settings.Href + "'"); 259 } 260 if (onClickEvents.Count > 0) 261 { 262 attributes.Add("onClick", string.Join(";", onClickEvents)); 263 } 264 265 if (settings.ButtonLayout != ButtonLayout.None) 266 { 267 classList.Add("btn"); 268 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 269 if (btnLayout == "linkclean") 270 { 271 btnLayout = "link-clean"; //fix 272 } 273 classList.Add("btn--" + btnLayout); 274 } 275 276 if (settings.Icon == null) 277 { 278 settings.Icon = new Icon(); 279 } 280 settings.Icon.Label = settings.Title; 281 282 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 283 284 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 285 } 286 } 287 288 @helper RenderConfirmDialog(Button settings) 289 { 290 Modal confirmDialog = new Modal { 291 Id = settings.Id, 292 Width = ModalWidth.Sm, 293 Heading = new Heading 294 { 295 Level = 2, 296 Title = settings.ConfirmTitle 297 }, 298 BodyText = settings.ConfirmText 299 }; 300 301 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 302 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 303 304 @Render(confirmDialog) 305 } 306 @using Dynamicweb.Rapido.Blocks.Components.General 307 @using Dynamicweb.Rapido.Blocks.Components 308 @using Dynamicweb.Core 309 310 @helper RenderDashboard(Dashboard settings) 311 { 312 var widgets = settings.GetWidgets(); 313 314 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 315 { 316 //set bg color for them 317 318 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 319 int r = Convert.ToInt16(color.R); 320 int g = Convert.ToInt16(color.G); 321 int b = Convert.ToInt16(color.B); 322 323 var count = widgets.Length; 324 var max = Math.Max(r, Math.Max(g, b)); 325 double step = 255.0 / (max * count); 326 var i = 0; 327 foreach (var widget in widgets) 328 { 329 i++; 330 331 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 332 widget.BackgroundColor = shade; 333 } 334 } 335 336 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 337 @foreach (var widget in widgets) 338 { 339 <div class="dashboard__widget"> 340 @Render(widget) 341 </div> 342 } 343 </div> 344 } 345 @using Dynamicweb.Rapido.Blocks.Components.General 346 @using Dynamicweb.Rapido.Blocks.Components 347 348 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 349 { 350 if (!string.IsNullOrEmpty(settings.Link)) 351 { 352 var backgroundStyles = ""; 353 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 354 { 355 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 356 } 357 358 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 359 <div class="u-center-middle u-color-light"> 360 @if (settings.Icon != null) 361 { 362 settings.Icon.CssClass += "widget__icon"; 363 @Render(settings.Icon) 364 } 365 <div class="widget__title">@settings.Title</div> 366 </div> 367 </a> 368 } 369 } 370 @using Dynamicweb.Rapido.Blocks.Components.General 371 @using Dynamicweb.Rapido.Blocks.Components 372 373 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 374 { 375 var backgroundStyles = ""; 376 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 377 { 378 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 379 } 380 381 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 382 <div class="u-center-middle u-color-light"> 383 @if (settings.Icon != null) 384 { 385 settings.Icon.CssClass += "widget__icon"; 386 @Render(settings.Icon) 387 } 388 <div class="widget__counter">@settings.Count</div> 389 <div class="widget__title">@settings.Title</div> 390 </div> 391 </div> 392 } 393 @using System.Reflection 394 @using Dynamicweb.Rapido.Blocks.Components.General 395 @using Dynamicweb.Rapido.Blocks.Components 396 @using Dynamicweb.Core 397 398 @* Component *@ 399 400 @helper RenderLink(Link settings) 401 { 402 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 403 { 404 Dictionary<string, string> attributes = new Dictionary<string, string>(); 405 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 406 if (settings.Disabled) 407 { 408 attributes.Add("disabled", "true"); 409 classList.Add("disabled"); 410 } 411 412 if (!string.IsNullOrEmpty(settings.AltText)) 413 { 414 attributes.Add("aria-label", settings.AltText); 415 } 416 417 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 418 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 419 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 420 attributes.Add("href", settings.Href); 421 422 if (settings.ButtonLayout != ButtonLayout.None) 423 { 424 classList.Add("btn"); 425 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 426 if (btnLayout == "linkclean") 427 { 428 btnLayout = "link-clean"; //fix 429 } 430 classList.Add("btn--" + btnLayout); 431 } 432 433 if (settings.Icon == null) 434 { 435 settings.Icon = new Icon(); 436 } 437 settings.Icon.Label = settings.Title; 438 439 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 440 { 441 settings.Rel = LinkRelType.Noopener; 442 } 443 if (settings.Target != LinkTargetType.None) 444 { 445 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 446 } 447 if (settings.Download) 448 { 449 attributes.Add("download", "true"); 450 } 451 if (settings.Rel != LinkRelType.None) 452 { 453 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 454 } 455 456 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 457 } 458 } 459 @using System.Reflection 460 @using Dynamicweb.Rapido.Blocks.Components 461 @using Dynamicweb.Rapido.Blocks.Components.General 462 @using Dynamicweb.Rapido.Blocks 463 464 465 @* Component *@ 466 467 @helper RenderRating(Rating settings) 468 { 469 if (settings.Score > 0) 470 { 471 int rating = settings.Score; 472 string iconType = "fa-star"; 473 474 switch (settings.Type.ToString()) { 475 case "Stars": 476 iconType = "fa-star"; 477 break; 478 case "Hearts": 479 iconType = "fa-heart"; 480 break; 481 case "Lemons": 482 iconType = "fa-lemon"; 483 break; 484 case "Bombs": 485 iconType = "fa-bomb"; 486 break; 487 } 488 489 <div class="u-ta-right"> 490 @for (int i = 0; i < settings.OutOf; i++) 491 { 492 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 493 } 494 </div> 495 } 496 } 497 @using System.Reflection 498 @using Dynamicweb.Rapido.Blocks.Components.General 499 @using Dynamicweb.Rapido.Blocks.Components 500 501 502 @* Component *@ 503 504 @helper RenderSelectFieldOption(SelectFieldOption settings) 505 { 506 Dictionary<string, string> attributes = new Dictionary<string, string>(); 507 if (settings.Checked) { attributes.Add("selected", "true"); } 508 if (settings.Disabled) { attributes.Add("disabled", "true"); } 509 if (settings.Value != null) { attributes.Add("value", settings.Value); } 510 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 511 512 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 513 } 514 @using System.Reflection 515 @using Dynamicweb.Rapido.Blocks.Components.General 516 @using Dynamicweb.Rapido.Blocks.Components 517 518 519 @* Component *@ 520 521 @helper RenderNavigation(Navigation settings) { 522 @RenderNavigation(new 523 { 524 id = settings.Id, 525 cssclass = settings.CssClass, 526 startLevel = settings.StartLevel, 527 endlevel = settings.EndLevel, 528 expandmode = settings.Expandmode, 529 sitemapmode = settings.SitemapMode, 530 template = settings.Template 531 }) 532 } 533 @using Dynamicweb.Rapido.Blocks.Components.General 534 @using Dynamicweb.Rapido.Blocks.Components 535 536 537 @* Component *@ 538 539 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 540 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 541 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 542 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 543 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 544 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 545 settings.SitemapMode = false; 546 547 @RenderNavigation(settings) 548 } 549 @using Dynamicweb.Rapido.Blocks.Components.General 550 @using Dynamicweb.Rapido.Blocks.Components 551 552 553 @* Component *@ 554 555 @helper RenderLeftNavigation(LeftNavigation settings) { 556 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 557 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 558 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 559 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 560 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 561 562 <div class="grid__cell"> 563 @RenderNavigation(settings) 564 </div> 565 } 566 @using System.Reflection 567 @using Dynamicweb.Rapido.Blocks.Components.General 568 @using Dynamicweb.Core 569 570 @* Component *@ 571 572 @helper RenderHeading(Heading settings) 573 { 574 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 575 { 576 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 577 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 578 579 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 580 if (!string.IsNullOrEmpty(settings.Link)) 581 { 582 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 583 } 584 else 585 { 586 if (settings.Icon == null) 587 { 588 settings.Icon = new Icon(); 589 } 590 settings.Icon.Label = settings.Title; 591 @Render(settings.Icon) 592 } 593 @("</" + tagName + ">"); 594 } 595 } 596 @using Dynamicweb.Rapido.Blocks.Components 597 @using Dynamicweb.Rapido.Blocks.Components.General 598 @using Dynamicweb.Rapido.Blocks 599 600 601 @* Component *@ 602 603 @helper RenderImage(Image settings) 604 { 605 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 606 { 607 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 608 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 609 610 if (settings.Caption != null) 611 { 612 @:<div> 613 } 614 615 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 616 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 617 618 <div class="image-filter [email protected] u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 619 <div class="image-filter [email protected] dw-mod"> 620 @if (settings.Link != null) 621 { 622 <a href="@settings.Link" tabindex="-1"> 623 @RenderTheImage(settings) 624 </a> 625 } 626 else 627 { 628 @RenderTheImage(settings) 629 } 630 </div> 631 </div> 632 633 if (settings.Caption != null) 634 { 635 <span class="image-caption dw-mod">@settings.Caption</span> 636 @:</div> 637 } 638 } 639 else 640 { 641 if (settings.Caption != null) 642 { 643 @:<div> 644 } 645 if (!string.IsNullOrEmpty(settings.Link)) 646 { 647 <a href="@settings.Link" tabindex="-1"> 648 @RenderTheImage(settings) 649 </a> 650 } 651 else 652 { 653 @RenderTheImage(settings) 654 } 655 656 if (settings.Caption != null) 657 { 658 <span class="image-caption dw-mod">@settings.Caption</span> 659 @:</div> 660 } 661 } 662 } 663 664 @helper RenderTheImage(Image settings) 665 { 666 if (settings != null) 667 { 668 string placeholderImage = "/Files/Images/placeholder.gif"; 669 string imageEngine = "/Admin/Public/GetImage.ashx?"; 670 671 string imageStyle = ""; 672 673 switch (settings.Style) 674 { 675 case ImageStyle.Ball: 676 imageStyle = "grid__cell-img--ball"; 677 break; 678 679 case ImageStyle.Triangle: 680 imageStyle = "grid__cell-img--triangle"; 681 break; 682 } 683 684 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 685 { 686 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 687 688 if (settings.ImageDefault != null) 689 { 690 settings.ImageDefault.Height = settings.ImageDefault.Width; 691 } 692 if (settings.ImageMedium != null) 693 { 694 settings.ImageMedium.Height = settings.ImageMedium.Width; 695 } 696 if (settings.ImageSmall != null) 697 { 698 settings.ImageSmall.Height = settings.ImageSmall.Width; 699 } 700 } 701 702 string defaultImage = imageEngine; 703 string imageSmall = ""; 704 string imageMedium = ""; 705 706 if (settings.DisableImageEngine) 707 { 708 defaultImage = settings.Path; 709 } 710 else 711 { 712 if (settings.ImageDefault != null) 713 { 714 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 715 716 if (settings.Path.GetType() != typeof(string)) 717 { 718 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 719 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 720 } 721 else 722 { 723 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 724 } 725 } 726 727 if (settings.ImageSmall != null) 728 { 729 imageSmall = "data-src-small=\"" + imageEngine; 730 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 731 732 if (settings.Path.GetType() != typeof(string)) 733 { 734 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 735 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 736 } 737 else 738 { 739 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 740 } 741 742 imageSmall += "\""; 743 } 744 745 if (settings.ImageMedium != null) 746 { 747 imageMedium = "data-src-medium=\"" + imageEngine; 748 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 749 750 if (settings.Path.GetType() != typeof(string)) 751 { 752 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 753 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 754 } 755 else 756 { 757 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 758 } 759 760 imageMedium += "\""; 761 } 762 } 763 764 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 765 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 766 if (!string.IsNullOrEmpty(settings.Title)) 767 { 768 optionalAttributes.Add("alt", settings.Title); 769 } 770 else 771 { 772 optionalAttributes.Add("alt", ""); 773 } 774 775 if (settings.DisableLazyLoad) 776 { 777 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 778 } 779 else 780 { 781 <img id="@settings.Id" class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 782 } 783 } 784 } 785 @using System.Reflection 786 @using Dynamicweb.Rapido.Blocks.Components.General 787 @using Dynamicweb.Rapido.Blocks.Components 788 789 @* Component *@ 790 791 @helper RenderFileField(FileField settings) 792 { 793 var attributes = new Dictionary<string, string>(); 794 if (string.IsNullOrEmpty(settings.Id)) 795 { 796 settings.Id = Guid.NewGuid().ToString("N"); 797 } 798 799 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 800 if (settings.Disabled) { attributes.Add("disabled", "true"); } 801 if (settings.Required) { attributes.Add("required", "true"); } 802 if (settings.Multiple) { attributes.Add("multiple", "true"); } 803 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 804 if (string.IsNullOrEmpty(settings.ChooseFileText)) 805 { 806 settings.ChooseFileText = Translate("Choose file"); 807 } 808 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 809 { 810 settings.NoFilesChosenText = Translate("No files chosen..."); 811 } 812 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 813 814 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 815 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 816 817 attributes.Add("type", "file"); 818 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 819 settings.CssClass = "u-full-width " + settings.CssClass; 820 821 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 822 823 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 824 @if (!string.IsNullOrEmpty(settings.Label)) 825 { 826 <label for="@settings.Id">@settings.Label</label> 827 } 828 @if (!string.IsNullOrEmpty(settings.HelpText)) 829 { 830 <small class="form__help-text">@settings.HelpText</small> 831 } 832 833 <div class="form__field-combi file-input u-no-margin dw-mod"> 834 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 835 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 836 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 837 @if (settings.UploadButton != null) 838 { 839 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 840 @Render(settings.UploadButton) 841 } 842 </div> 843 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 844 </div> 845 } 846 @using System.Reflection 847 @using Dynamicweb.Rapido.Blocks.Components.General 848 @using Dynamicweb.Rapido.Blocks.Components 849 @using Dynamicweb.Core 850 @using System.Linq 851 852 @* Component *@ 853 854 @helper RenderDateTimeField(DateTimeField settings) 855 { 856 if (string.IsNullOrEmpty(settings.Id)) 857 { 858 settings.Id = Guid.NewGuid().ToString("N"); 859 } 860 861 var textField = new TextField { 862 Name = settings.Name, 863 Id = settings.Id, 864 Label = settings.Label, 865 HelpText = settings.HelpText, 866 Value = settings.Value, 867 Disabled = settings.Disabled, 868 Required = settings.Required, 869 ErrorMessage = settings.ErrorMessage, 870 CssClass = settings.CssClass, 871 WrapperCssClass = settings.WrapperCssClass, 872 OnChange = settings.OnChange, 873 OnClick = settings.OnClick, 874 ExtraAttributes = settings.ExtraAttributes, 875 // 876 Placeholder = settings.Placeholder 877 }; 878 879 @Render(textField) 880 881 List<string> jsAttributes = new List<string>(); 882 883 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 884 885 if (!string.IsNullOrEmpty(settings.DateFormat)) 886 { 887 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 888 } 889 if (!string.IsNullOrEmpty(settings.MinDate)) 890 { 891 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 892 } 893 if (!string.IsNullOrEmpty(settings.MaxDate)) 894 { 895 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 896 } 897 if (settings.IsInline) 898 { 899 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 900 } 901 if (settings.EnableTime) 902 { 903 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 904 } 905 if (settings.EnableWeekNumbers) 906 { 907 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 908 } 909 910 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 911 912 <script> 913 document.addEventListener("DOMContentLoaded", function () { 914 flatpickr("#@textField.Id", { 915 @string.Join(",", jsAttributes) 916 }); 917 }); 918 </script> 919 } 920 @using System.Reflection 921 @using Dynamicweb.Rapido.Blocks.Components.General 922 @using Dynamicweb.Rapido.Blocks.Components 923 924 @* Component *@ 925 926 @helper RenderTextField(TextField settings) 927 { 928 var attributes = new Dictionary<string, string>(); 929 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 930 { 931 settings.Id = Guid.NewGuid().ToString("N"); 932 } 933 934 /*base settings*/ 935 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 936 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 937 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 938 if (settings.Disabled) { attributes.Add("disabled", "true"); } 939 if (settings.Required) { attributes.Add("required", "true"); } 940 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 941 /*end*/ 942 943 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 944 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 945 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 946 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 947 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 948 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 949 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 950 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 951 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 952 settings.CssClass = "u-full-width " + settings.CssClass; 953 954 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 955 956 string noMargin = "u-no-margin"; 957 if (!settings.ReadOnly) { 958 noMargin = ""; 959 } 960 961 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 962 @if (!string.IsNullOrEmpty(settings.Label)) 963 { 964 <label for="@settings.Id">@settings.Label</label> 965 } 966 @if (!string.IsNullOrEmpty(settings.HelpText)) 967 { 968 <small class="form__help-text">@settings.HelpText</small> 969 } 970 971 @if (settings.ActionButton != null) 972 { 973 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 974 <div class="form__field-combi u-no-margin dw-mod"> 975 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 976 @Render(settings.ActionButton) 977 </div> 978 } 979 else 980 { 981 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 982 } 983 984 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 985 </div> 986 } 987 @using System.Reflection 988 @using Dynamicweb.Rapido.Blocks.Components.General 989 @using Dynamicweb.Rapido.Blocks.Components 990 991 @* Component *@ 992 993 @helper RenderNumberField(NumberField settings) 994 { 995 var attributes = new Dictionary<string, string>(); 996 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 997 { 998 settings.Id = Guid.NewGuid().ToString("N"); 999 } 1000 1001 /*base settings*/ 1002 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1003 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1004 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1005 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1006 if (settings.Required) { attributes.Add("required", "true"); } 1007 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1008 /*end*/ 1009 1010 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1011 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1012 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1013 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1014 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1015 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1016 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1017 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1018 attributes.Add("type", "number"); 1019 1020 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1021 1022 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1023 @if (!string.IsNullOrEmpty(settings.Label)) 1024 { 1025 <label for="@settings.Id">@settings.Label</label> 1026 } 1027 @if (!string.IsNullOrEmpty(settings.HelpText)) 1028 { 1029 <small class="form__help-text">@settings.HelpText</small> 1030 } 1031 1032 @if (settings.ActionButton != null) 1033 { 1034 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1035 <div class="form__field-combi u-no-margin dw-mod"> 1036 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1037 @Render(settings.ActionButton) 1038 </div> 1039 } 1040 else 1041 { 1042 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1043 } 1044 1045 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1046 </div> 1047 } 1048 @using System.Reflection 1049 @using Dynamicweb.Rapido.Blocks.Components.General 1050 @using Dynamicweb.Rapido.Blocks.Components 1051 1052 1053 @* Component *@ 1054 1055 @helper RenderTextareaField(TextareaField settings) 1056 { 1057 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1058 string id = settings.Id; 1059 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1060 { 1061 id = Guid.NewGuid().ToString("N"); 1062 } 1063 1064 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1065 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1066 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1067 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1068 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1069 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1070 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1074 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1075 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1076 attributes.Add("name", settings.Name); 1077 1078 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1079 @if (!string.IsNullOrEmpty(settings.Label)) 1080 { 1081 <label for="@id">@settings.Label</label> 1082 } 1083 @if (!string.IsNullOrEmpty(settings.HelpText)) 1084 { 1085 <small class="form__help-text">@settings.HelpText</small> 1086 } 1087 1088 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1089 1090 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1091 </div> 1092 } 1093 @using System.Reflection 1094 @using Dynamicweb.Rapido.Blocks.Components.General 1095 @using Dynamicweb.Rapido.Blocks.Components 1096 1097 1098 @* Component *@ 1099 1100 @helper RenderHiddenField(HiddenField settings) { 1101 var attributes = new Dictionary<string, string>(); 1102 attributes.Add("type", "hidden"); 1103 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1104 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1105 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1106 1107 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1108 } 1109 @using System.Reflection 1110 @using Dynamicweb.Rapido.Blocks.Components.General 1111 @using Dynamicweb.Rapido.Blocks.Components 1112 1113 @* Component *@ 1114 1115 @helper RenderCheckboxField(CheckboxField settings) 1116 { 1117 var attributes = new Dictionary<string, string>(); 1118 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1119 { 1120 settings.Id = Guid.NewGuid().ToString("N"); 1121 } 1122 1123 /*base settings*/ 1124 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1125 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1126 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1127 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1128 if (settings.Required) { attributes.Add("required", "true"); } 1129 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1130 /*end*/ 1131 1132 attributes.Add("type", "checkbox"); 1133 if (settings.Checked) { attributes.Add("checked", "true"); } 1134 settings.CssClass = "form__control " + settings.CssClass; 1135 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1136 1137 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1138 1139 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1140 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1141 @if (!string.IsNullOrEmpty(settings.Label)) 1142 { 1143 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1144 } 1145 @if (!string.IsNullOrEmpty(settings.HelpText)) 1146 { 1147 <small class="form__help-text">@settings.HelpText</small> 1148 } 1149 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1150 </div> 1151 } 1152 @using System.Reflection 1153 @using Dynamicweb.Rapido.Blocks.Components.General 1154 @using Dynamicweb.Rapido.Blocks.Components 1155 1156 1157 @* Component *@ 1158 1159 @helper RenderCheckboxListField(CheckboxListField settings) 1160 { 1161 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1162 @if (!string.IsNullOrEmpty(settings.Label)) 1163 { 1164 <label>@settings.Label</label> 1165 } 1166 @if (!string.IsNullOrEmpty(settings.HelpText)) 1167 { 1168 <small class="form__help-text">@settings.HelpText</small> 1169 } 1170 1171 @foreach (var item in settings.Options) 1172 { 1173 if (settings.Required) 1174 { 1175 item.Required = true; 1176 } 1177 if (settings.Disabled) 1178 { 1179 item.Disabled = true; 1180 } 1181 if (!string.IsNullOrEmpty(settings.Name)) 1182 { 1183 item.Name = settings.Name; 1184 } 1185 if (!string.IsNullOrEmpty(settings.CssClass)) 1186 { 1187 item.CssClass += settings.CssClass; 1188 } 1189 1190 /* value is not supported */ 1191 1192 if (!string.IsNullOrEmpty(settings.OnClick)) 1193 { 1194 item.OnClick += settings.OnClick; 1195 } 1196 if (!string.IsNullOrEmpty(settings.OnChange)) 1197 { 1198 item.OnChange += settings.OnChange; 1199 } 1200 @Render(item) 1201 } 1202 1203 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1204 </div> 1205 } 1206 @using System.Reflection 1207 @using Dynamicweb.Rapido.Blocks.Components.General 1208 @using Dynamicweb.Rapido.Blocks.Components 1209 1210 1211 @* Component *@ 1212 1213 @helper RenderSelectField(SelectField settings) 1214 { 1215 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1216 { 1217 settings.Id = Guid.NewGuid().ToString("N"); 1218 } 1219 1220 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1221 @if (!string.IsNullOrEmpty(settings.Label)) 1222 { 1223 <label for="@settings.Id">@settings.Label</label> 1224 } 1225 @if (!string.IsNullOrEmpty(settings.HelpText)) 1226 { 1227 <small class="form__help-text">@settings.HelpText</small> 1228 } 1229 1230 @if (settings.ActionButton != null) 1231 { 1232 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1233 <div class="form__field-combi u-no-margin dw-mod"> 1234 @RenderSelectBase(settings) 1235 @Render(settings.ActionButton) 1236 </div> 1237 } 1238 else 1239 { 1240 @RenderSelectBase(settings) 1241 } 1242 1243 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1244 </div> 1245 } 1246 1247 @helper RenderSelectBase(SelectField settings) 1248 { 1249 var attributes = new Dictionary<string, string>(); 1250 1251 /*base settings*/ 1252 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1253 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1254 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1255 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1256 if (settings.Required) { attributes.Add("required", "true"); } 1257 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1258 /*end*/ 1259 1260 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1261 1262 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1263 @if (settings.Default != null) 1264 { 1265 @Render(settings.Default) 1266 } 1267 1268 @foreach (var item in settings.Options) 1269 { 1270 if (!string.IsNullOrEmpty(settings.Value)) { 1271 item.Checked = item.Value == settings.Value; 1272 } 1273 @Render(item) 1274 } 1275 </select> 1276 } 1277 @using System.Reflection 1278 @using Dynamicweb.Rapido.Blocks.Components.General 1279 @using Dynamicweb.Rapido.Blocks.Components 1280 1281 @* Component *@ 1282 1283 @helper RenderRadioButtonField(RadioButtonField settings) 1284 { 1285 var attributes = new Dictionary<string, string>(); 1286 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1287 { 1288 settings.Id = Guid.NewGuid().ToString("N"); 1289 } 1290 1291 /*base settings*/ 1292 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1293 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1294 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1295 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1296 if (settings.Required) { attributes.Add("required", "true"); } 1297 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1298 /*end*/ 1299 1300 attributes.Add("type", "radio"); 1301 if (settings.Checked) { attributes.Add("checked", "true"); } 1302 settings.CssClass = "form__control " + settings.CssClass; 1303 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1304 1305 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1306 1307 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1308 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1309 @if (!string.IsNullOrEmpty(settings.Label)) 1310 { 1311 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1312 } 1313 @if (!string.IsNullOrEmpty(settings.HelpText)) 1314 { 1315 <small class="form__help-text">@settings.HelpText</small> 1316 } 1317 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1318 </div> 1319 } 1320 @using System.Reflection 1321 @using Dynamicweb.Rapido.Blocks.Components.General 1322 @using Dynamicweb.Rapido.Blocks.Components 1323 1324 1325 @* Component *@ 1326 1327 @helper RenderRadioButtonListField(RadioButtonListField settings) 1328 { 1329 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1330 @if (!string.IsNullOrEmpty(settings.Label)) 1331 { 1332 <label>@settings.Label</label> 1333 } 1334 @if (!string.IsNullOrEmpty(settings.HelpText)) 1335 { 1336 <small class="form__help-text">@settings.HelpText</small> 1337 } 1338 1339 @foreach (var item in settings.Options) 1340 { 1341 if (settings.Required) 1342 { 1343 item.Required = true; 1344 } 1345 if (settings.Disabled) 1346 { 1347 item.Disabled = true; 1348 } 1349 if (!string.IsNullOrEmpty(settings.Name)) 1350 { 1351 item.Name = settings.Name; 1352 } 1353 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1354 { 1355 item.Checked = true; 1356 } 1357 if (!string.IsNullOrEmpty(settings.OnClick)) 1358 { 1359 item.OnClick += settings.OnClick; 1360 } 1361 if (!string.IsNullOrEmpty(settings.OnChange)) 1362 { 1363 item.OnChange += settings.OnChange; 1364 } 1365 if (!string.IsNullOrEmpty(settings.CssClass)) 1366 { 1367 item.CssClass += settings.CssClass; 1368 } 1369 @Render(item) 1370 } 1371 1372 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1373 </div> 1374 } 1375 @using System.Reflection 1376 @using Dynamicweb.Rapido.Blocks.Components.General 1377 @using Dynamicweb.Rapido.Blocks.Components 1378 1379 1380 @* Component *@ 1381 1382 @helper RenderNotificationMessage(NotificationMessage settings) 1383 { 1384 if (!string.IsNullOrEmpty(settings.Message)) 1385 { 1386 var attributes = new Dictionary<string, string>(); 1387 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1388 1389 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1390 <div class="[email protected] @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1391 } 1392 } 1393 @using Dynamicweb.Rapido.Blocks.Components.General 1394 1395 1396 @* Component *@ 1397 1398 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1399 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1400 1401 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1402 @if (settings.SubBlocks != null) { 1403 @RenderBlockList(settings.SubBlocks) 1404 } 1405 </div> 1406 } 1407 @using System.Reflection 1408 @using Dynamicweb.Rapido.Blocks.Components.General 1409 @using Dynamicweb.Rapido.Blocks.Components 1410 @using System.Text.RegularExpressions 1411 1412 1413 @* Component *@ 1414 1415 @helper RenderSticker(Sticker settings) { 1416 if (!String.IsNullOrEmpty(settings.Title)) { 1417 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1418 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1419 1420 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1421 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1422 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1423 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1424 optionalAttributes.Add("style", styleTag); 1425 } 1426 1427 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1428 } 1429 } 1430 1431 @using System.Reflection 1432 @using Dynamicweb.Rapido.Blocks.Components.General 1433 @using Dynamicweb.Rapido.Blocks.Components 1434 1435 1436 @* Component *@ 1437 1438 @helper RenderStickersCollection(StickersCollection settings) 1439 { 1440 if (settings.Stickers.Count > 0) 1441 { 1442 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1443 1444 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1445 @foreach (Sticker sticker in settings.Stickers) 1446 { 1447 @Render(sticker) 1448 } 1449 </div> 1450 } 1451 } 1452 1453 @using Dynamicweb.Rapido.Blocks.Components.General 1454 1455 1456 @* Component *@ 1457 1458 @helper RenderForm(Form settings) { 1459 if (settings != null) 1460 { 1461 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1462 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1463 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1464 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1465 var enctypes = new Dictionary<string, string> 1466 { 1467 { "multipart", "multipart/form-data" }, 1468 { "text", "text/plain" }, 1469 { "application", "application/x-www-form-urlencoded" } 1470 }; 1471 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1472 optionalAttributes.Add("method", settings.Method.ToString()); 1473 1474 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1475 { 1476 @settings.FormStartMarkup 1477 } 1478 else 1479 { 1480 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1481 } 1482 1483 foreach (var field in settings.GetFields()) 1484 { 1485 @Render(field) 1486 } 1487 1488 @:</form> 1489 } 1490 } 1491 @using System.Reflection 1492 @using Dynamicweb.Rapido.Blocks.Components.General 1493 @using Dynamicweb.Rapido.Blocks.Components 1494 1495 1496 @* Component *@ 1497 1498 @helper RenderText(Text settings) 1499 { 1500 @settings.Content 1501 } 1502 @using System.Reflection 1503 @using Dynamicweb.Rapido.Blocks.Components.General 1504 @using Dynamicweb.Rapido.Blocks.Components 1505 1506 1507 @* Component *@ 1508 1509 @helper RenderContentModule(ContentModule settings) { 1510 if (!string.IsNullOrEmpty(settings.Content)) 1511 { 1512 @settings.Content 1513 } 1514 } 1515 @using System.Reflection 1516 @using Dynamicweb.Rapido.Blocks.Components.General 1517 @using Dynamicweb.Rapido.Blocks.Components 1518 1519 1520 @* Component *@ 1521 1522 @helper RenderModal(Modal settings) { 1523 if (settings != null) 1524 { 1525 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1526 1527 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1528 1529 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1530 1531 <div class="modal-container"> 1532 @if (!settings.DisableDarkOverlay) 1533 { 1534 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1535 } 1536 <div class="modal modal--[email protected]().ToLower() [email protected]().ToLower()" id="@(modalId)Modal"> 1537 @if (settings.Heading != null) 1538 { 1539 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1540 { 1541 <div class="modal__header"> 1542 @Render(settings.Heading) 1543 </div> 1544 } 1545 } 1546 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1547 @if (!string.IsNullOrEmpty(settings.BodyText)) 1548 { 1549 @settings.BodyText 1550 } 1551 @if (settings.BodyTemplate != null) 1552 { 1553 @settings.BodyTemplate 1554 } 1555 @{ 1556 var actions = settings.GetActions(); 1557 } 1558 </div> 1559 @if (actions.Length > 0) 1560 { 1561 <div class="modal__footer"> 1562 @foreach (var action in actions) 1563 { 1564 action.CssClass += " u-no-margin"; 1565 @Render(action) 1566 } 1567 </div> 1568 } 1569 <label class="modal__close-btn" for="@(modalId)ModalTrigger" tabindex="0" onkeypress="fakeClickWithEnterKey(event, this)"><span class="u-sr-only">@Translate("Close Modal Window")</span></label> 1570 </div> 1571 </div> 1572 } 1573 } 1574 @using Dynamicweb.Rapido.Blocks.Components.General 1575 1576 @* Component *@ 1577 1578 @helper RenderMediaListItem(MediaListItem settings) 1579 { 1580 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1581 @if (!string.IsNullOrEmpty(settings.Label)) 1582 { 1583 if (!string.IsNullOrEmpty(settings.Link)) 1584 { 1585 @Render(new Link 1586 { 1587 Href = settings.Link, 1588 CssClass = "media-list-item__sticker dw-mod", 1589 ButtonLayout = ButtonLayout.None, 1590 Title = settings.Label, 1591 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1592 }) 1593 } 1594 else if (!string.IsNullOrEmpty(settings.OnClick)) 1595 { 1596 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1597 <span class="u-uppercase">@settings.Label</span> 1598 </span> 1599 } 1600 else 1601 { 1602 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1603 <span class="u-uppercase">@settings.Label</span> 1604 </span> 1605 } 1606 } 1607 <div class="media-list-item__wrap"> 1608 <div class="media-list-item__info dw-mod"> 1609 <div class="media-list-item__header dw-mod"> 1610 @if (!string.IsNullOrEmpty(settings.Title)) 1611 { 1612 if (!string.IsNullOrEmpty(settings.Link)) 1613 { 1614 @Render(new Link 1615 { 1616 Href = settings.Link, 1617 CssClass = "media-list-item__name dw-mod", 1618 ButtonLayout = ButtonLayout.None, 1619 Title = settings.Title, 1620 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1621 }) 1622 } 1623 else if (!string.IsNullOrEmpty(settings.OnClick)) 1624 { 1625 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1626 } 1627 else 1628 { 1629 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1630 } 1631 } 1632 1633 @if (!string.IsNullOrEmpty(settings.Status)) 1634 { 1635 <div class="media-list-item__state dw-mod">@settings.Status</div> 1636 } 1637 </div> 1638 @{ 1639 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1640 } 1641 1642 @Render(settings.InfoTable) 1643 </div> 1644 <div class="media-list-item__actions dw-mod"> 1645 <div class="media-list-item__actions-list dw-mod"> 1646 @{ 1647 var actions = settings.GetActions(); 1648 1649 foreach (ButtonBase action in actions) 1650 { 1651 action.ButtonLayout = ButtonLayout.None; 1652 action.CssClass += " media-list-item__action link"; 1653 1654 @Render(action) 1655 } 1656 } 1657 </div> 1658 1659 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1660 { 1661 settings.SelectButton.CssClass += " u-no-margin"; 1662 1663 <div class="media-list-item__action-button"> 1664 @Render(settings.SelectButton) 1665 </div> 1666 } 1667 </div> 1668 </div> 1669 </div> 1670 } 1671 @using Dynamicweb.Rapido.Blocks.Components.General 1672 @using Dynamicweb.Rapido.Blocks.Components 1673 1674 @helper RenderTable(Table settings) 1675 { 1676 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1677 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1678 1679 var enumToClasses = new Dictionary<TableDesign, string> 1680 { 1681 { TableDesign.Clean, "table--clean" }, 1682 { TableDesign.Bordered, "table--bordered" }, 1683 { TableDesign.Striped, "table--striped" }, 1684 { TableDesign.Hover, "table--hover" }, 1685 { TableDesign.Compact, "table--compact" }, 1686 { TableDesign.Condensed, "table--condensed" }, 1687 { TableDesign.NoTopBorder, "table--no-top-border" } 1688 }; 1689 string tableDesignClass = ""; 1690 if (settings.Design != TableDesign.None) 1691 { 1692 tableDesignClass = enumToClasses[settings.Design]; 1693 } 1694 1695 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1696 1697 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1698 1699 <table @ComponentMethods.AddAttributes(resultAttributes)> 1700 @if (settings.Header != null) 1701 { 1702 <thead> 1703 @Render(settings.Header) 1704 </thead> 1705 } 1706 <tbody> 1707 @foreach (var row in settings.Rows) 1708 { 1709 @Render(row) 1710 } 1711 </tbody> 1712 @if (settings.Footer != null) 1713 { 1714 <tfoot> 1715 @Render(settings.Footer) 1716 </tfoot> 1717 } 1718 </table> 1719 } 1720 @using Dynamicweb.Rapido.Blocks.Components.General 1721 @using Dynamicweb.Rapido.Blocks.Components 1722 1723 @helper RenderTableRow(TableRow settings) 1724 { 1725 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1726 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1727 1728 var enumToClasses = new Dictionary<TableRowDesign, string> 1729 { 1730 { TableRowDesign.NoBorder, "table__row--no-border" }, 1731 { TableRowDesign.Border, "table__row--border" }, 1732 { TableRowDesign.TopBorder, "table__row--top-line" }, 1733 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1734 { TableRowDesign.Solid, "table__row--solid" } 1735 }; 1736 1737 string tableRowDesignClass = ""; 1738 if (settings.Design != TableRowDesign.None) 1739 { 1740 tableRowDesignClass = enumToClasses[settings.Design]; 1741 } 1742 1743 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1744 1745 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1746 1747 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1748 @foreach (var cell in settings.Cells) 1749 { 1750 if (settings.IsHeaderRow) 1751 { 1752 cell.IsHeader = true; 1753 } 1754 @Render(cell) 1755 } 1756 </tr> 1757 } 1758 @using Dynamicweb.Rapido.Blocks.Components.General 1759 @using Dynamicweb.Rapido.Blocks.Components 1760 @using Dynamicweb.Core 1761 1762 @helper RenderTableCell(TableCell settings) 1763 { 1764 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1765 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1766 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1767 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1768 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1769 1770 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1771 1772 string tagName = settings.IsHeader ? "th" : "td"; 1773 1774 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1775 @settings.Content 1776 @("</" + tagName + ">"); 1777 } 1778 @using System.Linq 1779 @using Dynamicweb.Rapido.Blocks.Components.General 1780 1781 @* Component *@ 1782 1783 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1784 { 1785 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1786 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1787 1788 if (settings.NumberOfPages > 1) 1789 { 1790 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1791 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Pagination"); 1792 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1793 1794 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1795 @if (settings.ShowPagingInfo) 1796 { 1797 <div class="pager__info dw-mod"> 1798 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1799 </div> 1800 } 1801 <ul class="pager__list dw-mod" role="navigation" aria-label='@Translate("Pagination")'> 1802 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1803 { 1804 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1805 } 1806 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1807 { 1808 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon, HelperName = "Prev"}) 1809 } 1810 @if (settings.GetPages().Any()) 1811 { 1812 foreach (var page in settings.GetPages()) 1813 { 1814 @Render(page) 1815 } 1816 } 1817 else 1818 { 1819 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1820 { 1821 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1822 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1823 } 1824 } 1825 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1826 { 1827 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon, HelperName = "Next" }) 1828 } 1829 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1830 { 1831 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1832 } 1833 </ul> 1834 </div> 1835 } 1836 } 1837 1838 @helper RenderPaginationItem(PaginationItem settings) 1839 { 1840 var ariaLabel = settings.HelperName == "Prev" ? Translate("Go to Previous page") : settings.HelperName == "Next" ? Translate("Go to Next page") : $"{Translate("Go to page")} {settings.Label}"; 1841 1842 if (settings.Icon == null) 1843 { 1844 settings.Icon = new Icon(); 1845 } 1846 1847 settings.Icon.Label = settings.Label; 1848 <li class="pager__btn dw-mod"> 1849 @if (settings.IsActive) 1850 { 1851 <span class="pager__num pager__num--current dw-mod"> 1852 <span class="u-sr-only">@Translate("Current page")</span> 1853 @Render(settings.Icon) 1854 </span> 1855 } 1856 else 1857 { 1858 <a href="@settings.Link" class="pager__num dw-mod" aria-label="@ariaLabel"> 1859 @Render(settings.Icon) 1860 </a> 1861 } 1862 </li> 1863 } 1864 1865 1866 1867 1868 1869 @using System.Reflection 1870 @using Dynamicweb.Rapido.Blocks.Components.General 1871 @using Dynamicweb.Rapido.Blocks.Components 1872 1873 @* Component *@ 1874 1875 @helper RenderFileFieldCustom(FileField settings) 1876 { 1877 var attributes = new Dictionary<string, string>(); 1878 if (string.IsNullOrEmpty(settings.Id)) 1879 { 1880 settings.Id = Guid.NewGuid().ToString("N"); 1881 } 1882 1883 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1884 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1885 if (settings.Required) { attributes.Add("required", "true"); } 1886 if (settings.Multiple) { attributes.Add("multiple", "true"); } 1887 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1888 if (string.IsNullOrEmpty(settings.ChooseFileText)) 1889 { 1890 settings.ChooseFileText = Translate("Choose file"); 1891 } 1892 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 1893 { 1894 settings.NoFilesChosenText = Translate("No files chosen..."); 1895 } 1896 1897 attributes.Add("type", "file"); 1898 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1899 settings.CssClass = "u-full-width " + settings.CssClass; 1900 1901 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1902 var filesListId = settings.Id + "_wgoFilesList"; 1903 1904 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1905 @if (!string.IsNullOrEmpty(settings.Label)) 1906 { 1907 <label for="@settings.Id">@settings.Label</label> 1908 } 1909 @if (!string.IsNullOrEmpty(settings.HelpText)) 1910 { 1911 <small class="form__help-text">@settings.HelpText</small> 1912 } 1913 1914 <div class="form__field-combi file-input u-no-margin dw-mod wgo-file-input u-ta-center"> 1915 <input aria-label="@settings.ChooseFileText" aria-labelledby="@filesListId" @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 1916 1917 <div id="@filesListId" class="@settings.CssClass dw-mod wgo-file-input-files-list">@settings.NoFilesChosenText</div> 1918 <div> 1919 <button type="button" class="file-input__btn btn--secondary btn dw-mod wgo-file-input-clear">Clear</button> 1920 <button type="button" class="file-input__btn btn--secondary btn dw-mod wgo-file-input-add">@settings.ChooseFileText</button> 1921 </div> 1922 @if (settings.UploadButton != null) 1923 { 1924 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 1925 @Render(settings.UploadButton) 1926 } 1927 </div> 1928 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1929 </div> 1930 } 1931 @using Dynamicweb.Frontend 1932 @using Dynamicweb.Rapido.Blocks.Components 1933 @using Dynamicweb.Rapido.Blocks.Components.General 1934 @using Dynamicweb.Rapido.Blocks 1935 1936 @* Component *@ 1937 1938 @helper RenderImageCustom(Image settings) 1939 { 1940 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 1941 { 1942 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1943 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 1944 1945 if (settings.Caption != null) 1946 { 1947 @:<div> 1948 } 1949 1950 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 1951 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 1952 1953 <div class="image-filter [email protected] u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 1954 <div class="image-filter [email protected] dw-mod"> 1955 @if (settings.Link != null) 1956 { 1957 <a href="@settings.Link" tabindex="-1"> 1958 @* START CUSTOM CODE: call custom helper *@ 1959 @RenderTheImageCustom(settings) 1960 @* END CUSTOM CODE *@ 1961 </a> 1962 } 1963 else 1964 { 1965 @* START CUSTOM CODE: call custom helper *@ 1966 @RenderTheImageCustom(settings) 1967 @* END CUSTOM CODE *@ 1968 } 1969 </div> 1970 </div> 1971 1972 if (settings.Caption != null) 1973 { 1974 <span class="image-caption dw-mod">@settings.Caption</span> 1975 @:</div> 1976 } 1977 } 1978 else 1979 { 1980 if (settings.Caption != null) 1981 { 1982 @:<div> 1983 } 1984 if (!string.IsNullOrEmpty(settings.Link)) 1985 { 1986 <a href="@settings.Link" tabindex="-1"> 1987 @* START CUSTOM CODE: call custom helper *@ 1988 @RenderTheImageCustom(settings) 1989 @* END CUSTOM CODE *@ 1990 </a> 1991 } 1992 else 1993 { 1994 @* START CUSTOM CODE: call custom helper *@ 1995 @RenderTheImageCustom(settings) 1996 @* END CUSTOM CODE *@ 1997 } 1998 1999 if (settings.Caption != null) 2000 { 2001 <span class="image-caption dw-mod">@settings.Caption</span> 2002 @:</div> 2003 } 2004 } 2005 } 2006 2007 @helper RenderTheImageCustom(Image settings) 2008 { 2009 if (settings != null) 2010 { 2011 string placeholderImage = "/Files/Images/placeholder.gif"; 2012 string imageEngine = "/Admin/Public/GetImage.ashx?"; 2013 2014 string imageStyle = ""; 2015 2016 switch (settings.Style) 2017 { 2018 case ImageStyle.Ball: 2019 imageStyle = "grid__cell-img--ball"; 2020 break; 2021 2022 case ImageStyle.Triangle: 2023 imageStyle = "grid__cell-img--triangle"; 2024 break; 2025 } 2026 2027 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 2028 { 2029 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 2030 2031 if (settings.ImageDefault != null) 2032 { 2033 settings.ImageDefault.Height = settings.ImageDefault.Width; 2034 } 2035 if (settings.ImageMedium != null) 2036 { 2037 settings.ImageMedium.Height = settings.ImageMedium.Width; 2038 } 2039 if (settings.ImageSmall != null) 2040 { 2041 settings.ImageSmall.Height = settings.ImageSmall.Width; 2042 } 2043 } 2044 2045 string defaultImage = imageEngine; 2046 string imageSmall = ""; 2047 string imageMedium = ""; 2048 2049 // START CUSTOM CODE: Add ends with svg validation 2050 if (settings.DisableImageEngine || settings.Path.ToString().EndsWith(".svg")) 2051 // END CUSTOM CODE 2052 { 2053 defaultImage = settings.Path; 2054 2055 if (settings.ImageDefault != null) 2056 { 2057 placeholderImage = imageEngine + Dna.Winnebago.Services.Images.GetImagePathFromSettings(settings.ImageDefault) + "Image=" + placeholderImage; 2058 } 2059 } 2060 else 2061 { 2062 if (settings.ImageDefault != null) 2063 { 2064 // START CUSTOM CODE: Custom GetImagePathFromSettings 2065 defaultImage += Dna.Winnebago.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 2066 placeholderImage = imageEngine + Dna.Winnebago.Services.Images.GetImagePathFromSettings(settings.ImageDefault) + "Image=" + placeholderImage; 2067 //END CUSTOM CODE 2068 2069 if (settings.Path.GetType() != typeof(string)) 2070 { 2071 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 2072 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 2073 } 2074 else 2075 { 2076 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 2077 } 2078 } 2079 2080 if (settings.ImageSmall != null) 2081 { 2082 imageSmall = "data-src-small=\"" + imageEngine; 2083 // START CUSTOM CODE: Custom GetImagePathFromSettings 2084 imageSmall += Dna.Winnebago.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 2085 //END CUSTOM CODE 2086 2087 if (settings.Path.GetType() != typeof(string)) 2088 { 2089 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 2090 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 2091 } 2092 else 2093 { 2094 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 2095 } 2096 2097 imageSmall += "\""; 2098 } 2099 2100 if (settings.ImageMedium != null) 2101 { 2102 imageMedium = "data-src-medium=\"" + imageEngine; 2103 // START CUSTOM CODE: Custom GetImagePathFromSettings 2104 imageMedium += Dna.Winnebago.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 2105 //END CUSTOM CODE 2106 2107 if (settings.Path.GetType() != typeof(string)) 2108 { 2109 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 2110 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 2111 } 2112 else 2113 { 2114 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 2115 } 2116 2117 imageMedium += "\""; 2118 } 2119 } 2120 2121 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2122 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 2123 if (!string.IsNullOrEmpty(settings.Title)) 2124 { 2125 optionalAttributes.Add("alt", settings.Title); 2126 } 2127 else 2128 { 2129 optionalAttributes.Add("alt", ""); 2130 } 2131 2132 // START CUSTOM CODE: get default height and width 2133 var height = ""; 2134 var width = ""; 2135 2136 if (settings.ImageDefault?.Width > 0 && settings.ImageDefault?.Height > 0) 2137 { 2138 height = "height='" + settings.ImageDefault.Height + "'"; 2139 width = "width='" + settings.ImageDefault.Width + "'"; 2140 } 2141 // END CUSTOM CODE 2142 2143 if (settings.DisableLazyLoad) 2144 { 2145 <img id="@settings.Id" @height @width class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 2146 } 2147 else 2148 { 2149 <img id="@settings.Id" @height @width class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 2150 } 2151 } 2152 } 2153 @using System 2154 @using Dynamicweb.Rapido.Blocks.Components.General 2155 @using Dynamicweb.Rapido.Blocks.Components.Articles 2156 @* Component *@ 2157 2158 @helper RenderArticleBannerCustom(ArticleHeader settings) 2159 { 2160 string filterClasses = "image-filter image-filter--darken"; 2161 settings.Layout = ArticleHeaderLayout.Banner; 2162 2163 if (settings.Image != null) 2164 { 2165 if (settings.Image.Path != null) 2166 { 2167 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2168 <div class="background-image @filterClasses dw-mod"> 2169 <div class="background-image__wrapper @filterClasses dw-mod"> 2170 @{ 2171 settings.Image.CssClass += "background-image__cover dw-mod"; 2172 } 2173 @Render(settings.Image) 2174 </div> 2175 </div> 2176 <div class="center-container dw-mod"> 2177 <div class="grid"> 2178 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg"> 2179 <div class="u-left-middle"> 2180 <div> 2181 <div class="article--date--and--category u-flex grid--align-center grid--justify-center"> 2182 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2183 { 2184 <div class="article__post-info dw-mod item" style="color: @settings.TextColor">@settings.Author @settings.Date</div> 2185 } 2186 @if (!String.IsNullOrEmpty(settings.Category)) 2187 { 2188 <div class="item"> 2189 <div class="article__category dw-mod">@settings.Category</div> 2190 </div> 2191 } 2192 </div> 2193 @if (!String.IsNullOrEmpty(settings.Heading)) 2194 { 2195 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2196 } 2197 @if (!String.IsNullOrEmpty(settings.Subheading)) 2198 { 2199 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2200 } 2201 @if (!String.IsNullOrEmpty(settings.Link)) 2202 { 2203 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2204 } 2205 @if (!String.IsNullOrEmpty(settings.Link)) 2206 { 2207 <div class="grid__cell"> 2208 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2209 </div> 2210 } 2211 </div> 2212 </div> 2213 </div> 2214 @if (settings.ExternalParagraphId != 0) 2215 { 2216 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod"> 2217 <div class="u-color-light-gray--bg u-color-dark dw-mod"> 2218 @RenderParagraphContent(settings.ExternalParagraphId) 2219 </div> 2220 </div> 2221 } 2222 2223 </div> 2224 </div> 2225 </section> 2226 if (!String.IsNullOrEmpty(settings.Image.Caption)) 2227 { 2228 <div class="image-caption dw-mod">@settings.Image.Caption</div> 2229 } 2230 } 2231 else 2232 { 2233 settings.Layout = ArticleHeaderLayout.Clean; 2234 @RenderArticleCleanHeaderCustom(settings); 2235 } 2236 } 2237 else 2238 { 2239 settings.Layout = ArticleHeaderLayout.Clean; 2240 @RenderArticleCleanHeaderCustom(settings); 2241 } 2242 } 2243 2244 @helper RenderArticleCleanHeaderCustom(ArticleHeader settings) 2245 { 2246 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2247 2248 <div class="grid grid--align-content-start grid--justify-start"> 2249 <div class="[email protected] grid__col-sm-12 u-padding--lg dw-mod"> 2250 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0) 2251 { 2252 <div class="article--date--and--category u-flex grid--align-center grid--justify-center"> 2253 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2254 { 2255 <div class="article__post-info dw-mod item" style="color: @settings.TextColor">@settings.Author @settings.Date</div> 2256 } 2257 @if (!String.IsNullOrEmpty(settings.Category)) 2258 { 2259 <div class="item"> 2260 <div class="article__category dw-mod">@settings.Category</div> 2261 </div> 2262 } 2263 </div> 2264 } 2265 2266 <div class="grid__cell"> 2267 @if (!String.IsNullOrEmpty(settings.Heading)) 2268 { 2269 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2270 } 2271 @if (settings.Image != null) 2272 { 2273 if (settings.Image.Path != null) 2274 { 2275 <div class="u-padding-bottom--lg"> 2276 @Render(settings.Image) 2277 </div> 2278 } 2279 } 2280 @if (!String.IsNullOrEmpty(settings.Subheading)) 2281 { 2282 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2283 } 2284 @if (!String.IsNullOrEmpty(settings.Link)) 2285 { 2286 <div class="grid__cell"> 2287 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2288 </div> 2289 } 2290 </div> 2291 </div> 2292 @if (settings.ExternalParagraphId != 0) 2293 { 2294 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod"> 2295 @RenderParagraphContent(settings.ExternalParagraphId) 2296 </div> 2297 } 2298 </div> 2299 } 2300 2301 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2302 2303 2304 @* 2305 This is a temporary fallback for the DefaultImage. The image pattern MUST be set up like this: 2306 2307 ImageSmall = /{ProductNumber}.jpg 2308 ImageMedium = /{ProductNumber}{VariantOptionLevel1}.jpg 2309 ImageLarge = /{ProductNumber}{VariantComboName}.jpg 2310 2311 In addition to the ImageDefault setting 2312 *@ 2313 2314 @functions { 2315 public string GetProductImage(LoopItem productObject = null) 2316 { 2317 string theImage = ""; 2318 2319 if (productObject == null) { 2320 theImage = GetString("Ecom:Product.ImageDefault.Default.Clean"); 2321 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageLarge.Clean") : theImage; 2322 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageMedium.Clean") : theImage; 2323 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageSmall.Clean") : theImage; 2324 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageLarge.Default.Clean") : theImage; 2325 } else { 2326 theImage = productObject.GetString("Ecom:Product.ImageDefault.Default.Clean"); 2327 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageLarge.Clean") : theImage; 2328 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageMedium.Clean") : theImage; 2329 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageSmall.Clean") : theImage; 2330 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageLarge.Default.Clean") : theImage; 2331 } 2332 2333 return theImage; 2334 } 2335 } 2336 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2337 @using System.Linq 2338 @using Dynamicweb.Core 2339 @using Dynamicweb.Frontend.Devices 2340 @using Dynamicweb.Rapido.Blocks 2341 @using Dynamicweb.Rapido.Blocks.Components.General 2342 @{ 2343 var virtualLaunchPage = Dynamicweb.Services.Pages.GetAncestors(Pageview.Page.ID, true).FirstOrDefault(p => p.ItemType.Equals("VirtualLaunchPage")); 2344 var virtualLaunchPageHeading = virtualLaunchPage?.Item["GroupsPageHeading"].ToString(); 2345 var virtualLaunchPageId = virtualLaunchPage?.ID ?? Pageview.Page.ID; 2346 var heading = !string.IsNullOrEmpty(GetString("Ecom:Group:Field.VirtualLaunchModelsHeading.Value")) ? GetString("Ecom:Group:Field.VirtualLaunchModelsHeading.Value") : virtualLaunchPageHeading; 2347 var headingComponent = new Heading 2348 { 2349 Title = Converter.ToString(Render(new Link 2350 { 2351 Href = "/Default.aspx?ID=" + virtualLaunchPageId, 2352 Title = heading, 2353 ButtonLayout = ButtonLayout.None, 2354 CssClass = "u-padding u-font--inherit u-product-title--side-lines u-product-title--side-lines--thick" 2355 })), 2356 Level = 1, 2357 CssClass = "u-uppercase u-letter-spacing--xs u-ta-center u-color-light u-brand-color-one--bg u-no-margin" 2358 }; 2359 2360 if (Pageview.Page.ID.Equals(virtualLaunchPageId)) 2361 { 2362 headingComponent.Title = heading; 2363 headingComponent.CssClass += " u-padding u-product-title--side-lines u-product-title--side-lines--thick"; 2364 } 2365 2366 var lineupHeadingBlock = new Block 2367 { 2368 Id = "VirtualLaunchLineupHeading", 2369 SortId = 10, 2370 Design = new Design { Size = "12", RenderType = RenderType.Column, HidePadding = true, CssClass = "paragraph-container--full-width virtual-launch-lineup-heading" }, 2371 Component = headingComponent 2372 }; 2373 } 2374 @using Dynamicweb.Core 2375 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2376 @functions 2377 { 2378 private static bool IsGetRevealPageParameterInQuery() 2379 { 2380 var myUri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri); 2381 var getRevealPageParam = HttpUtility.ParseQueryString(myUri.Query).Get("GetRevealPage"); 2382 2383 return getRevealPageParam == "KbasnmPermission"; 2384 } 2385 2386 private Dynamicweb.Content.Page GetRevealPage() 2387 { 2388 var virtualLaunchPage = Dynamicweb.Services.Pages.GetAncestors(Pageview.Page.ID, true).FirstOrDefault(p => p.ItemType.Equals("VirtualLaunchPage")); 2389 2390 if (virtualLaunchPage == null) { return null; } 2391 2392 var virtualRevealLink = virtualLaunchPage.Item["LaunchPage"]?.ToString(); 2393 var virtualRevealId = !string.IsNullOrEmpty(virtualRevealLink) ? Converter.ToInt32(virtualRevealLink.Replace("Default.aspx?Id=", "")) : 0; 2394 return Dynamicweb.Services.Pages.GetPage(virtualRevealId); 2395 } 2396 2397 private bool IsGroupPageLive(DateTime validFrom) 2398 { 2399 var timeDifference = validFrom - DateTime.Now; 2400 2401 var virtualLaunchValidFrom = GetRevealPage().ActiveFrom; 2402 var timeDifferenceVirtualLaunch = virtualLaunchValidFrom - DateTime.Now; 2403 2404 // Unblocking pages 90 seconds earlier to account for possible server time differences 2405 var spreadIntervalToUnblockPage = 90; 2406 var groupIsLive = timeDifference.TotalSeconds < spreadIntervalToUnblockPage; 2407 var virtualLaunchIsLive = timeDifferenceVirtualLaunch.TotalSeconds < spreadIntervalToUnblockPage; 2408 2409 return (groupIsLive && virtualLaunchIsLive) || IsGetRevealPageParameterInQuery(); 2410 } 2411 } 2412 @functions 2413 { 2414 BlocksPage virtualLaunchProductListBlocksPage = BlocksPage.GetBlockPage("VirtualLaunchProductList"); 2415 2416 // NOTE: Workaround because DW 9.7.2 has a bug with the Repository that is not storing the group sorting 2417 private Dictionary<int, string> GetProductSorting() 2418 { 2419 var groupSorting = new Dictionary<int, string>(); 2420 var currentGroupId = HttpContext.Current.Request.QueryString.Get("GroupID"); 2421 var currentGroup = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(currentGroupId); 2422 var index = 1; 2423 2424 foreach (var product in currentGroup.Products.Where(p => p.VariantId.Equals(""))) 2425 { 2426 groupSorting.Add(index, product.Id); 2427 index++; 2428 } 2429 2430 return groupSorting; 2431 } 2432 } 2433 @{ 2434 var groupSorting = GetProductSorting(); 2435 2436 if (!IsGroupPageLive(GetDate("Ecom:Group:Field.VirtualLaunchValidFrom"))) 2437 { 2438 HttpContext.Current.Response.Redirect($"/{Pageview.Area.NotFound}"); 2439 } 2440 2441 var groupBanner = GetString("Ecom:Group:Field.VirtualLaunchBanner"); 2442 var groupBannerPageId = !string.IsNullOrEmpty(groupBanner) ? groupBanner.Replace("Default.aspx?Id=", "") : ""; 2443 if (!string.IsNullOrEmpty(groupBannerPageId)) 2444 { 2445 virtualLaunchProductListBlocksPage.Add(new Block() 2446 { 2447 Id = "VirtualLaunchProductListBanner", 2448 Component = new Text { Content = Converter.ToString(RenderPageContent(Converter.ToInt32(groupBannerPageId))) }, 2449 SortId = 5 2450 }); 2451 } 2452 2453 virtualLaunchProductListBlocksPage.Add(lineupHeadingBlock); 2454 2455 virtualLaunchProductListBlocksPage.Add(new Block() 2456 { 2457 Id = "VirtualLaunchProductListContainerRow", 2458 Design = new Design { RenderType = RenderType.Row, HidePadding = true }, 2459 SortId = 15 2460 }); 2461 2462 virtualLaunchProductListBlocksPage.GetBlockById("VirtualLaunchProductListContainerRow")?.Add(new Block() 2463 { 2464 Id = "VirtualLaunchProductListContainerWrapper", 2465 Design = new Design 2466 { 2467 Size = "12", 2468 RenderType = RenderType.Column, 2469 HidePadding = true, 2470 CssClass = "paragraph-container--full-width virtual-launch-models-list-wrapper u-margin-top--lg" 2471 }, 2472 SortId = 10, 2473 BlocksList = new List<Block> 2474 { 2475 new Block 2476 { 2477 Id = "VirtualLaunchProductListContainer", 2478 SortId = 10, 2479 Template = RenderProductList(), 2480 SkipRenderBlocksList = true 2481 } 2482 } 2483 }); 2484 2485 foreach (var product in GetLoop("Products")) 2486 { 2487 virtualLaunchProductListBlocksPage.GetBlockById("VirtualLaunchProductListContainer")?.Add(new Block() 2488 { 2489 Id = "VirtualLaunchProduct_" + product.GetString("Ecom:Product.Name"), 2490 SortId = 10 * groupSorting.FirstOrDefault(x => x.Value == product.GetString("Ecom:Product.ID")).Key, 2491 Template = RenderProducts(product) 2492 }); 2493 } 2494 2495 virtualLaunchProductListBlocksPage.Add(new Block() 2496 { 2497 Id = "VirtualLaunchModelsListScroll", 2498 Design = new Design 2499 { 2500 Size = "12", 2501 RenderType = RenderType.Column, 2502 HidePadding = true, 2503 CssClass = "paragraph-container--full-width u-inline-block u-color-dark--bg virtual-launch-models-list-scroll" 2504 }, 2505 SortId = 20, 2506 Template = RenderHorizontalScroll() 2507 }); 2508 2509 virtualLaunchProductListBlocksPage.Add(new Block() 2510 { 2511 Id = "VirtualLaunchProductDetail", 2512 Design = new Design {Size = "12", RenderType = RenderType.Column}, 2513 SortId = 30, 2514 }); 2515 2516 virtualLaunchProductListBlocksPage.Add(new Block() 2517 { 2518 Id = "VirtualLaunchMapsScript", 2519 SortId = 40, 2520 Template = RenderMapsScript() 2521 }); 2522 } 2523 2524 @RenderBlockList(virtualLaunchProductListBlocksPage.BlocksRoot.BlocksList) 2525 2526 @helper RenderProductList() { 2527 <ul class="virtual-launch-models-list-container">@RenderBlockList(virtualLaunchProductListBlocksPage.GetBlockById("VirtualLaunchProductListContainer").BlocksList)</ul> 2528 } 2529 2530 @helper RenderProducts(LoopItem product) 2531 { 2532 var metadata = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(product.GetString("Ecom:Product:Field.VPLModelListThumbnail.Clean")); 2533 var imageMetaAltText = metadata?.GetValue("Alt_text") ?? string.Empty; 2534 var imageAltText = product.GetString("Ecom:Product.ImageDefault.Metadata.Alt_Text"); 2535 var imageTitle = !string.IsNullOrEmpty(imageMetaAltText) ? imageMetaAltText : !string.IsNullOrEmpty(imageAltText) ? imageAltText : string.Empty; 2536 var productDetailUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(product.GetString("Ecom:Product.LinkGroup.Clean")); 2537 2538 if (IsGetRevealPageParameterInQuery()) 2539 { 2540 productDetailUrl += "?GetRevealPage=KbasnmPermission"; 2541 } 2542 2543 <li tabindex="0" onkeypress="fakeClickWithEnterKey(event, this)" id="@product.GetString("Ecom:Product.Name")" class="u-inline-block u-ta-center u-cursor-pointer virtual-launch-models-list-product" 2544 data-product-name="@product.GetString("Ecom:Product.Name")" 2545 data-product-detail="@productDetailUrl" 2546 onclick="VirtualLaunch.GetProductDetail(this , '' , true)"> 2547 @Render(new Image() 2548 { 2549 Path = product.GetString("Ecom:Product:Field.VPLModelListThumbnail.Clean"), 2550 Title = imageTitle, 2551 ImageDefault = new ImageSettings { Width = 400, Height = 200, Crop = 7, FillCanvas = true } 2552 }) 2553 @* needed to add role=link. rendered like this because Heading does not contain a definition for ExtraAttributes *@ 2554 <div class="u-inline-block u-uppercase u-margin-top h6 dw-mod" role="link">@product.GetString("Ecom:Product.Name")</div> 2555 </li> 2556 } 2557 2558 @helper RenderHorizontalScroll() 2559 { 2560 var cssClasses = "u-inline-block u-color-white u-no-margin models-list-arrow"; 2561 @Render(new Button 2562 { 2563 ButtonLayout = ButtonLayout.Clean, 2564 CssClass = cssClasses + " models-list-arrow--left", 2565 Icon = new Icon {Prefix = "fas", Name = "fa-arrow-left", CssClass = "u-hidden"}, 2566 OnClick = "VirtualLaunch.HandleHorizontalScroll('left')", 2567 ExtraAttributes = {{"aria-hidden", "true"}, {"tabindex", "-1"}} 2568 }) 2569 2570 @Render(new Button 2571 { 2572 ButtonLayout = ButtonLayout.Clean, 2573 CssClass = cssClasses + " u-pull--right models-list-arrow--right", 2574 Icon = new Icon {Prefix = "fas", Name = "fa-arrow-right"}, 2575 OnClick = "VirtualLaunch.HandleHorizontalScroll('right')", 2576 ExtraAttributes = {{"aria-hidden", "true"}, {"tabindex", "-1"}} 2577 }) 2578 } 2579 2580 @helper RenderMapsScript() 2581 { 2582 var googleMapsApiKey = Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey"); 2583 <script async defer src="https://maps.googleapis.com/maps/api/[email protected]&libraries=geometry"></script> 2584 }