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