4.5
Man-Tor: 9-17:30 | Fre: 9-18 | Lør: 10-14 | Søn: Lukket
Error executing template "Designs/Rapido/ContentPage/Paragraph/TopBannerWithRecommendation.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_6f10182205924764a211b978a944e872.Execute() in C:\Dynamicweb.Net\Solutions\Philipson Wine Test\Files\Templates\Designs\Rapido\ContentPage\Paragraph\TopBannerWithRecommendation.cshtml:line 2203
   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.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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

En unik og uforglemmelig oplevelse

Vinsmagning som gaveidé

Er du på udkig efter en unik fødselsdagsgave, jubilæumsgave eller bryllupsgave? Så kan en vinsmagning være det perfekte valg – især til ham eller hende, der elsker god vin. Det er en invitation til at udforske en verden af aromaer, farver og smagsnuancer, der kan åbne døren til nye præferencer og opdagelser.

Rødvin

Rødvin er danskernes absolut foretrukne valg af vin, og derfor har vi selvfølgelig sørget for at have et solidt udvalg af rødvin fra hele verden fremstillet på alle druetyper.

Hvidvin

Hvidvin er en skøn og alsidig drik, der nydes af vinelskere verden over. Vinen kan fremstilles på mange forskellige druesorter, som alle har hver deres særlige egenskaber.

Rosévin

Rosévin er en populær vin, der kommer i et væld af varianter. Druerne, som den enkelte rosévin er lavet på, dikterer smagen, og vinene kan derfor være alt fra friske, frugtige og sprøde til tørre, aromatiske, fyldige og krydrede.

Mousserende vin

Intet signalerer fest, som når korkproppen springes fra en mousserende vin. Bare lyden får de fleste i godt humør. Hos Philipson Wine har vi et stort udvalg af de bedste mousserende vine, som kan opdrives.