Travato

Travato

Logo

Travato

The Travato® is the top-selling Camper Van in North America for a reason. Several reasons, actually. Energy and fuel-efficient systems make the most of the Travato’s ample power. And streamlined features are designed to keep you traveling even when the elements – and the road – are less than forgiving.

Learn more on the Travato and the Pure3 Advanced Energy System

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

WinnebagoLife

As you forge new paths, share your stories and engage with others about the lessons and joy that only the open road can provide.

Service

No one knows your Winnebago better than you. Except for maybe our highly-trained quality technicians at our factory service areas. Locate dealers, or find innovative self-help tools here, and you'll be back behind the wheel in no time.

Outdoor Adventures

If you’re looking for incredible destinations and connections with fellow restless spirits, Winnebago Outdoor Adventures is ready to roll.

Gear

With women’s and men’s apparel and gear like drinkware, koozies decals and more you’ll be more than covered when you’re covering more ground.

WIT Club

You don't just buy a Winnebago, you join a community. The WIT Club is a society of travelers that make up the longest manufacturer-managed club in the country.