Error executing template "Designs/Rapido/_parsed/DynamicArticle.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_92bb72fc44504172ab2ca3206c3c0df5.Execute() in E:\Solutions\Rapido\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8173
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.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 RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   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.PageViewModel> 2 3 @using System.Web; 4 @using Dynamicweb.Frontend 5 @using Dynamicweb.Frontend.Devices 6 @using Dynamicweb.Extensibility 7 @using Dynamicweb.Content 8 @using Dynamicweb.Security 9 @using Dynamicweb.Core 10 @using System 11 @using System.Web 12 @using System.IO 13 @using Dynamicweb.Rapido.Blocks 14 @using System.Net 15 16 17 @functions { 18 BlocksPage masterPage = BlocksPage.GetBlockPage("Master"); 19 20 string getFontFamily(params string[] items) 21 { 22 var itemParent = Pageview.AreaSettings; 23 foreach (var item in items) 24 { 25 itemParent = itemParent.GetItem(item); 26 if (itemParent == null) 27 { 28 return null; 29 } 30 } 31 32 var googleFont = itemParent.GetGoogleFont("FontFamily"); 33 if (googleFont == null) 34 { 35 return null; 36 } 37 return googleFont.Family.Replace(" ", "+"); 38 } 39 } 40 41 @{ 42 Block root = new Block 43 { 44 Id = "Root", 45 SortId = 10, 46 BlocksList = new List<Block> 47 { 48 new Block { 49 Id = "Head", 50 SortId = 10, 51 SkipRenderBlocksList = true, 52 Template = RenderMasterHead(), 53 BlocksList = new List<Block> 54 { 55 new Block { 56 Id = "HeadMetadata", 57 SortId = 10, 58 Template = RenderMasterMetadata(), 59 }, 60 new Block { 61 Id = "HeadCss", 62 SortId = 20, 63 Template = RenderMasterCss(), 64 }, 65 new Block { 66 Id = "HeadManifest", 67 SortId = 30, 68 Template = RenderMasterManifest(), 69 } 70 } 71 }, 72 new Block { 73 Id = "Body", 74 SortId = 20, 75 SkipRenderBlocksList = true, 76 Template = RenderMasterBody(), 77 BlocksList = new List<Block> 78 { 79 new Block() 80 { 81 Id = "Master", 82 SortId = 10, 83 BlocksList = new List<Block> { 84 new Block { 85 Id = "MasterTopSnippets", 86 SortId = 10 87 }, 88 new Block { 89 Id = "MasterMain", 90 SortId = 20, 91 Template = RenderMain(), 92 SkipRenderBlocksList = true, 93 BlocksList = new List<Block> { 94 new Block { 95 Id = "MasterHeader", 96 SortId = 10, 97 Template = RenderMasterHeader(), 98 SkipRenderBlocksList = true 99 }, 100 new Block { 101 Id = "MasterPageContent", 102 SortId = 20, 103 Template = RenderPageContent() 104 } 105 } 106 }, 107 new Block { 108 Id = "MasterFooter", 109 SortId = 30 110 }, 111 new Block { 112 Id = "MasterReferences", 113 SortId = 40 114 }, 115 new Block { 116 Id = "MasterBottomSnippets", 117 SortId = 50 118 } 119 } 120 } 121 } 122 } 123 } 124 }; 125 126 masterPage.Add(root); 127 } 128 129 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 130 @using System.Text.RegularExpressions 131 @using System.Collections.Generic 132 @using System.Reflection 133 @using System.Web 134 @using System.Web.UI.HtmlControls 135 @using Dynamicweb.Rapido.Blocks.Components 136 @using Dynamicweb.Rapido.Blocks.Components.Articles 137 @using Dynamicweb.Rapido.Blocks.Components.Documentation 138 @using Dynamicweb.Rapido.Blocks 139 140 141 @*--- START: Base block renderers ---*@ 142 143 @helper RenderBlockList(List<Block> blocks) 144 { 145 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 146 blocks = blocks.OrderBy(item => item.SortId).ToList(); 147 148 foreach (Block item in blocks) 149 { 150 if (debug) { 151 <!-- Block START: @item.Id --> 152 } 153 154 if (item.Design == null) 155 { 156 @RenderBlock(item) 157 } 158 else if (item.Design.RenderType == RenderType.None) { 159 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 160 161 <div class="@cssClass dw-mod"> 162 @RenderBlock(item) 163 </div> 164 } 165 else if (item.Design.RenderType != RenderType.Hide) 166 { 167 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 168 169 if (!item.SkipRenderBlocksList) { 170 if (item.Design.RenderType == RenderType.Row) 171 { 172 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 173 @RenderBlock(item) 174 </div> 175 } 176 177 if (item.Design.RenderType == RenderType.Column) 178 { 179 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 180 string size = item.Design.Size ?? "12"; 181 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 182 183 <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"> 184 @RenderBlock(item) 185 </div> 186 } 187 188 if (item.Design.RenderType == RenderType.Table) 189 { 190 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 191 @RenderBlock(item) 192 </table> 193 } 194 195 if (item.Design.RenderType == RenderType.TableRow) 196 { 197 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 198 @RenderBlock(item) 199 </tr> 200 } 201 202 if (item.Design.RenderType == RenderType.TableColumn) 203 { 204 <td class="@cssClass dw-mod" id="Block__@item.Id"> 205 @RenderBlock(item) 206 </td> 207 } 208 209 if (item.Design.RenderType == RenderType.CardHeader) 210 { 211 <div class="card-header @cssClass dw-mod"> 212 @RenderBlock(item) 213 </div> 214 } 215 216 if (item.Design.RenderType == RenderType.CardBody) 217 { 218 <div class="card @cssClass dw-mod"> 219 @RenderBlock(item) 220 </div> 221 } 222 223 if (item.Design.RenderType == RenderType.CardFooter) 224 { 225 <div class="card-footer @cssClass dw-mod"> 226 @RenderBlock(item) 227 </div> 228 } 229 } 230 else 231 { 232 @RenderBlock(item) 233 } 234 } 235 236 if (debug) { 237 <!-- Block END: @item.Id --> 238 } 239 } 240 } 241 242 @helper RenderBlock(Block item) 243 { 244 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 245 246 if (item.Template != null) 247 { 248 @BlocksPage.RenderTemplate(item.Template) 249 } 250 251 if (item.Component != null) 252 { 253 string customSufix = "Custom"; 254 string methodName = item.Component.HelperName; 255 256 ComponentBase[] methodParameters = new ComponentBase[1]; 257 methodParameters[0] = item.Component; 258 Type methodType = this.GetType(); 259 260 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 261 MethodInfo generalMethod = methodType.GetMethod(methodName); 262 263 try { 264 if (debug) { 265 <!-- Component: @methodName.Replace("Render", "") --> 266 } 267 @customMethod.Invoke(this, methodParameters).ToString(); 268 } catch { 269 try { 270 @generalMethod.Invoke(this, methodParameters).ToString(); 271 } catch(Exception ex) { 272 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 273 } 274 } 275 } 276 277 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 278 { 279 @RenderBlockList(item.BlocksList) 280 } 281 } 282 283 @*--- END: Base block renderers ---*@ 284 285 286 @* Include the components *@ 287 @using Dynamicweb.Rapido.Blocks.Components 288 @using Dynamicweb.Rapido.Blocks.Components.General 289 @using Dynamicweb.Rapido.Blocks 290 @using System.IO 291 292 @* Required *@ 293 @using Dynamicweb.Rapido.Blocks.Components 294 @using Dynamicweb.Rapido.Blocks.Components.General 295 @using Dynamicweb.Rapido.Blocks 296 297 298 @helper Render(ComponentBase component) 299 { 300 if (component != null) 301 { 302 @component.Render(this) 303 } 304 } 305 306 @* Components *@ 307 @using System.Reflection 308 @using Dynamicweb.Rapido.Blocks.Components.General 309 310 311 @* Component *@ 312 313 @helper RenderIcon(Icon settings) 314 { 315 if (settings != null) 316 { 317 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 318 319 if (settings.Name != null) 320 { 321 if (string.IsNullOrEmpty(settings.Label)) 322 { 323 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 324 } 325 else 326 { 327 if (settings.LabelPosition == IconLabelPosition.Before) 328 { 329 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 330 } 331 else 332 { 333 <span><i class="@settings.Prefix @settings.Name u-margin-right--lg @settings.CssClass u-w20px" @color></i>@settings.Label</span> 334 } 335 } 336 } 337 else if (!string.IsNullOrEmpty(settings.Label)) 338 { 339 @settings.Label 340 } 341 } 342 } 343 @using System.Reflection 344 @using Dynamicweb.Rapido.Blocks.Components.General 345 @using Dynamicweb.Rapido.Blocks.Components 346 @using Dynamicweb.Core 347 348 @* Component *@ 349 350 @helper RenderButton(Button settings) 351 { 352 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 353 { 354 Dictionary<string, string> attributes = new Dictionary<string, string>(); 355 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 356 if (settings.Disabled) { 357 attributes.Add("disabled", "true"); 358 classList.Add("disabled"); 359 } 360 361 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 362 { 363 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 364 @RenderConfirmDialog(settings); 365 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 366 } 367 368 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 369 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 370 if (!string.IsNullOrEmpty(settings.AltText)) 371 { 372 attributes.Add("title", settings.AltText); 373 } 374 else if (!string.IsNullOrEmpty(settings.Title)) 375 { 376 attributes.Add("title", settings.Title); 377 } 378 379 var onClickEvents = new List<string>(); 380 if (!string.IsNullOrEmpty(settings.OnClick)) 381 { 382 onClickEvents.Add(settings.OnClick); 383 } 384 if (!string.IsNullOrEmpty(settings.Href)) 385 { 386 onClickEvents.Add("location.href='" + settings.Href + "'"); 387 } 388 if (onClickEvents.Count > 0) 389 { 390 attributes.Add("onClick", string.Join(";", onClickEvents)); 391 } 392 393 if (settings.ButtonLayout != ButtonLayout.None) 394 { 395 classList.Add("btn"); 396 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 397 if (btnLayout == "linkclean") 398 { 399 btnLayout = "link-clean"; //fix 400 } 401 classList.Add("btn--" + btnLayout); 402 } 403 404 if (settings.Icon == null) 405 { 406 settings.Icon = new Icon(); 407 } 408 settings.Icon.Label = settings.Title; 409 410 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 411 412 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 413 } 414 } 415 416 @helper RenderConfirmDialog(Button settings) 417 { 418 Modal confirmDialog = new Modal { 419 Id = settings.Id, 420 Width = ModalWidth.Sm, 421 Heading = new Heading 422 { 423 Level = 2, 424 Title = settings.ConfirmTitle 425 }, 426 BodyText = settings.ConfirmText 427 }; 428 429 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 430 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 431 432 @Render(confirmDialog) 433 } 434 @using Dynamicweb.Rapido.Blocks.Components.General 435 @using Dynamicweb.Rapido.Blocks.Components 436 @using Dynamicweb.Core 437 438 @helper RenderDashboard(Dashboard settings) 439 { 440 var widgets = settings.GetWidgets(); 441 442 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 443 { 444 //set bg color for them 445 446 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 447 int r = Convert.ToInt16(color.R); 448 int g = Convert.ToInt16(color.G); 449 int b = Convert.ToInt16(color.B); 450 451 var count = widgets.Length; 452 var max = Math.Max(r, Math.Max(g, b)); 453 double step = 255.0 / (max * count); 454 var i = 0; 455 foreach (var widget in widgets) 456 { 457 i++; 458 459 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 460 widget.BackgroundColor = shade; 461 } 462 } 463 464 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 465 @foreach (var widget in widgets) 466 { 467 <div class="dashboard__widget"> 468 @Render(widget) 469 </div> 470 } 471 </div> 472 } 473 @using Dynamicweb.Rapido.Blocks.Components.General 474 @using Dynamicweb.Rapido.Blocks.Components 475 476 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 477 { 478 if (!string.IsNullOrEmpty(settings.Link)) 479 { 480 var backgroundStyles = ""; 481 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 482 { 483 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 484 } 485 486 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 487 <div class="u-center-middle u-color-light"> 488 @if (settings.Icon != null) 489 { 490 settings.Icon.CssClass += "widget__icon"; 491 @Render(settings.Icon) 492 } 493 <div class="widget__title">@settings.Title</div> 494 </div> 495 </a> 496 } 497 } 498 @using Dynamicweb.Rapido.Blocks.Components.General 499 @using Dynamicweb.Rapido.Blocks.Components 500 501 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 502 { 503 var backgroundStyles = ""; 504 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 505 { 506 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 507 } 508 509 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 510 <div class="u-center-middle u-color-light"> 511 @if (settings.Icon != null) 512 { 513 settings.Icon.CssClass += "widget__icon"; 514 @Render(settings.Icon) 515 } 516 <div class="widget__counter">@settings.Count</div> 517 <div class="widget__title">@settings.Title</div> 518 </div> 519 </div> 520 } 521 @using System.Reflection 522 @using Dynamicweb.Rapido.Blocks.Components.General 523 @using Dynamicweb.Rapido.Blocks.Components 524 @using Dynamicweb.Core 525 526 @* Component *@ 527 528 @helper RenderLink(Link settings) 529 { 530 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 531 { 532 Dictionary<string, string> attributes = new Dictionary<string, string>(); 533 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 534 if (settings.Disabled) 535 { 536 attributes.Add("disabled", "true"); 537 classList.Add("disabled"); 538 } 539 540 if (!string.IsNullOrEmpty(settings.AltText)) 541 { 542 attributes.Add("title", settings.AltText); 543 } 544 else if (!string.IsNullOrEmpty(settings.Title)) 545 { 546 attributes.Add("title", settings.Title); 547 } 548 549 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 550 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 551 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 552 attributes.Add("href", settings.Href); 553 554 if (settings.ButtonLayout != ButtonLayout.None) 555 { 556 classList.Add("btn"); 557 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 558 if (btnLayout == "linkclean") 559 { 560 btnLayout = "link-clean"; //fix 561 } 562 classList.Add("btn--" + btnLayout); 563 } 564 565 if (settings.Icon == null) 566 { 567 settings.Icon = new Icon(); 568 } 569 settings.Icon.Label = settings.Title; 570 571 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 572 { 573 settings.Rel = LinkRelType.Noopener; 574 } 575 if (settings.Target != LinkTargetType.None) 576 { 577 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 578 } 579 if (settings.Download) 580 { 581 attributes.Add("download", "true"); 582 } 583 if (settings.Rel != LinkRelType.None) 584 { 585 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 586 } 587 588 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 589 } 590 } 591 @using System.Reflection 592 @using Dynamicweb.Rapido.Blocks.Components 593 @using Dynamicweb.Rapido.Blocks.Components.General 594 @using Dynamicweb.Rapido.Blocks 595 596 597 @* Component *@ 598 599 @helper RenderRating(Rating settings) 600 { 601 if (settings.Score > 0) 602 { 603 int rating = settings.Score; 604 string iconType = "fa-star"; 605 606 switch (settings.Type.ToString()) { 607 case "Stars": 608 iconType = "fa-star"; 609 break; 610 case "Hearts": 611 iconType = "fa-heart"; 612 break; 613 case "Lemons": 614 iconType = "fa-lemon"; 615 break; 616 case "Bombs": 617 iconType = "fa-bomb"; 618 break; 619 } 620 621 <div class="u-ta-right"> 622 @for (int i = 0; i < settings.OutOf; i++) 623 { 624 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 625 } 626 </div> 627 } 628 } 629 @using System.Reflection 630 @using Dynamicweb.Rapido.Blocks.Components.General 631 @using Dynamicweb.Rapido.Blocks.Components 632 633 634 @* Component *@ 635 636 @helper RenderSelectFieldOption(SelectFieldOption settings) 637 { 638 Dictionary<string, string> attributes = new Dictionary<string, string>(); 639 if (settings.Checked) { attributes.Add("selected", "true"); } 640 if (settings.Disabled) { attributes.Add("disabled", "true"); } 641 if (settings.Value != null) { attributes.Add("value", settings.Value); } 642 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 643 644 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 645 } 646 @using System.Reflection 647 @using Dynamicweb.Rapido.Blocks.Components.General 648 @using Dynamicweb.Rapido.Blocks.Components 649 650 651 @* Component *@ 652 653 @helper RenderNavigation(Navigation settings) { 654 @RenderNavigation(new 655 { 656 id = settings.Id, 657 cssclass = settings.CssClass, 658 startLevel = settings.StartLevel, 659 endlevel = settings.EndLevel, 660 expandmode = settings.Expandmode, 661 sitemapmode = settings.SitemapMode, 662 template = settings.Template 663 }) 664 } 665 @using Dynamicweb.Rapido.Blocks.Components.General 666 @using Dynamicweb.Rapido.Blocks.Components 667 668 669 @* Component *@ 670 671 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 672 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 673 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 674 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 675 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 676 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 677 settings.SitemapMode = false; 678 679 @RenderNavigation(settings) 680 } 681 @using Dynamicweb.Rapido.Blocks.Components.General 682 @using Dynamicweb.Rapido.Blocks.Components 683 684 685 @* Component *@ 686 687 @helper RenderLeftNavigation(LeftNavigation settings) { 688 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 689 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 690 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 691 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 692 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 693 694 <div class="grid__cell"> 695 @RenderNavigation(settings) 696 </div> 697 } 698 @using System.Reflection 699 @using Dynamicweb.Rapido.Blocks.Components.General 700 @using Dynamicweb.Core 701 702 @* Component *@ 703 704 @helper RenderHeading(Heading settings) 705 { 706 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 707 { 708 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 709 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 710 711 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 712 if (!string.IsNullOrEmpty(settings.Link)) 713 { 714 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 715 } 716 else 717 { 718 if (settings.Icon == null) 719 { 720 settings.Icon = new Icon(); 721 } 722 settings.Icon.Label = settings.Title; 723 @Render(settings.Icon) 724 } 725 @("</" + tagName + ">"); 726 } 727 } 728 @using Dynamicweb.Rapido.Blocks.Components 729 @using Dynamicweb.Rapido.Blocks.Components.General 730 @using Dynamicweb.Rapido.Blocks 731 732 733 @* Component *@ 734 735 @helper RenderImage(Image settings) 736 { 737 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 738 { 739 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 740 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 741 742 if (settings.Caption != null) 743 { 744 @:<div> 745 } 746 747 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 748 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 749 750 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 751 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 752 @if (settings.Link != null) 753 { 754 <a href="@settings.Link"> 755 @RenderTheImage(settings) 756 </a> 757 } 758 else 759 { 760 @RenderTheImage(settings) 761 } 762 </div> 763 </div> 764 765 if (settings.Caption != null) 766 { 767 <span class="image-caption dw-mod">@settings.Caption</span> 768 @:</div> 769 } 770 } 771 else 772 { 773 if (settings.Caption != null) 774 { 775 @:<div> 776 } 777 if (!string.IsNullOrEmpty(settings.Link)) 778 { 779 <a href="@settings.Link"> 780 @RenderTheImage(settings) 781 </a> 782 } 783 else 784 { 785 @RenderTheImage(settings) 786 } 787 788 if (settings.Caption != null) 789 { 790 <span class="image-caption dw-mod">@settings.Caption</span> 791 @:</div> 792 } 793 } 794 } 795 796 @helper RenderTheImage(Image settings) 797 { 798 if (settings != null) 799 { 800 string placeholderImage = "/Files/Images/placeholder.gif"; 801 string imageEngine = "/Admin/Public/GetImage.ashx?"; 802 803 string imageStyle = ""; 804 805 switch (settings.Style) 806 { 807 case ImageStyle.Ball: 808 imageStyle = "grid__cell-img--ball"; 809 break; 810 811 case ImageStyle.Triangle: 812 imageStyle = "grid__cell-img--triangle"; 813 break; 814 } 815 816 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 817 { 818 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 819 820 if (settings.ImageDefault != null) 821 { 822 settings.ImageDefault.Height = settings.ImageDefault.Width; 823 } 824 if (settings.ImageMedium != null) 825 { 826 settings.ImageMedium.Height = settings.ImageMedium.Width; 827 } 828 if (settings.ImageSmall != null) 829 { 830 settings.ImageSmall.Height = settings.ImageSmall.Width; 831 } 832 } 833 834 string defaultImage = imageEngine; 835 string imageSmall = ""; 836 string imageMedium = ""; 837 838 if (settings.DisableImageEngine) 839 { 840 defaultImage = settings.Path; 841 } 842 else 843 { 844 if (settings.ImageDefault != null) 845 { 846 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 847 848 if (settings.Path.GetType() != typeof(string)) 849 { 850 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 851 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 852 } 853 else 854 { 855 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 856 } 857 } 858 859 if (settings.ImageSmall != null) 860 { 861 imageSmall = "data-src-small=\"" + imageEngine; 862 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 863 864 if (settings.Path.GetType() != typeof(string)) 865 { 866 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 867 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 868 } 869 else 870 { 871 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 872 } 873 874 imageSmall += "\""; 875 } 876 877 if (settings.ImageMedium != null) 878 { 879 imageMedium = "data-src-medium=\"" + imageEngine; 880 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 881 882 if (settings.Path.GetType() != typeof(string)) 883 { 884 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 885 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 886 } 887 else 888 { 889 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 890 } 891 892 imageMedium += "\""; 893 } 894 } 895 896 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 897 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 898 if (!string.IsNullOrEmpty(settings.Title)) 899 { 900 optionalAttributes.Add("alt", settings.Title); 901 optionalAttributes.Add("title", settings.Title); 902 } 903 904 if (settings.DisableLazyLoad) 905 { 906 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 907 } 908 else 909 { 910 <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) /> 911 } 912 } 913 } 914 @using System.Reflection 915 @using Dynamicweb.Rapido.Blocks.Components.General 916 @using Dynamicweb.Rapido.Blocks.Components 917 918 @* Component *@ 919 920 @helper RenderFileField(FileField settings) 921 { 922 var attributes = new Dictionary<string, string>(); 923 if (string.IsNullOrEmpty(settings.Id)) 924 { 925 settings.Id = Guid.NewGuid().ToString("N"); 926 } 927 928 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 929 if (settings.Disabled) { attributes.Add("disabled", "true"); } 930 if (settings.Required) { attributes.Add("required", "true"); } 931 if (settings.Multiple) { attributes.Add("multiple", "true"); } 932 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 933 if (string.IsNullOrEmpty(settings.ChooseFileText)) 934 { 935 settings.ChooseFileText = Translate("Choose file"); 936 } 937 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 938 { 939 settings.NoFilesChosenText = Translate("No files chosen..."); 940 } 941 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 942 943 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 944 945 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 946 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 947 948 attributes.Add("type", "file"); 949 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 950 settings.CssClass = "u-full-width " + settings.CssClass; 951 952 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 953 954 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 955 @if (!string.IsNullOrEmpty(settings.Label)) 956 { 957 <label for="@settings.Id">@settings.Label</label> 958 } 959 @if (!string.IsNullOrEmpty(settings.HelpText)) 960 { 961 <small class="form__help-text">@settings.HelpText</small> 962 } 963 964 <div class="form__field-combi file-input u-no-margin dw-mod"> 965 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 966 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 967 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 968 @if (settings.UploadButton != null) 969 { 970 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 971 @Render(settings.UploadButton) 972 } 973 </div> 974 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 975 </div> 976 } 977 @using System.Reflection 978 @using Dynamicweb.Rapido.Blocks.Components.General 979 @using Dynamicweb.Rapido.Blocks.Components 980 @using Dynamicweb.Core 981 @using System.Linq 982 983 @* Component *@ 984 985 @helper RenderDateTimeField(DateTimeField settings) 986 { 987 if (string.IsNullOrEmpty(settings.Id)) 988 { 989 settings.Id = Guid.NewGuid().ToString("N"); 990 } 991 992 var textField = new TextField { 993 Name = settings.Name, 994 Id = settings.Id, 995 Label = settings.Label, 996 HelpText = settings.HelpText, 997 Value = settings.Value, 998 Disabled = settings.Disabled, 999 Required = settings.Required, 1000 ErrorMessage = settings.ErrorMessage, 1001 CssClass = settings.CssClass, 1002 WrapperCssClass = settings.WrapperCssClass, 1003 OnChange = settings.OnChange, 1004 OnClick = settings.OnClick, 1005 ExtraAttributes = settings.ExtraAttributes, 1006 // 1007 Placeholder = settings.Placeholder 1008 }; 1009 1010 @Render(textField) 1011 1012 List<string> jsAttributes = new List<string>(); 1013 1014 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1015 1016 if (!string.IsNullOrEmpty(settings.DateFormat)) 1017 { 1018 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1019 } 1020 if (!string.IsNullOrEmpty(settings.MinDate)) 1021 { 1022 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1023 } 1024 if (!string.IsNullOrEmpty(settings.MaxDate)) 1025 { 1026 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1027 } 1028 if (settings.IsInline) 1029 { 1030 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1031 } 1032 if (settings.EnableTime) 1033 { 1034 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1035 } 1036 if (settings.EnableWeekNumbers) 1037 { 1038 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1039 } 1040 1041 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1042 1043 <script> 1044 document.addEventListener("DOMContentLoaded", function () { 1045 flatpickr("#@textField.Id", { 1046 @string.Join(",", jsAttributes) 1047 }); 1048 }); 1049 </script> 1050 } 1051 @using System.Reflection 1052 @using Dynamicweb.Rapido.Blocks.Components.General 1053 @using Dynamicweb.Rapido.Blocks.Components 1054 1055 @* Component *@ 1056 1057 @helper RenderTextField(TextField settings) 1058 { 1059 var attributes = new Dictionary<string, string>(); 1060 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1061 { 1062 settings.Id = Guid.NewGuid().ToString("N"); 1063 } 1064 1065 /*base settings*/ 1066 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1067 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1068 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1069 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1070 if (settings.Required) { attributes.Add("required", "true"); } 1071 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1072 /*end*/ 1073 1074 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1075 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1076 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1077 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1078 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1079 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1080 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1081 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1082 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1083 settings.CssClass = "u-full-width " + settings.CssClass; 1084 1085 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1086 1087 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1088 1089 string noMargin = "u-no-margin"; 1090 if (!settings.ReadOnly) { 1091 noMargin = ""; 1092 } 1093 1094 <div class="form__field-group u-full-width @noMargin @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 @* Component *@ 1125 1126 @helper RenderNumberField(NumberField settings) 1127 { 1128 var attributes = new Dictionary<string, string>(); 1129 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1130 { 1131 settings.Id = Guid.NewGuid().ToString("N"); 1132 } 1133 1134 /*base settings*/ 1135 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1136 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1137 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1138 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1139 if (settings.Required) { attributes.Add("required", "true"); } 1140 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1141 /*end*/ 1142 1143 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1144 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1145 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1146 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1147 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1148 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1149 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1150 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1151 attributes.Add("type", "number"); 1152 1153 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1154 1155 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1156 @if (!string.IsNullOrEmpty(settings.Label)) 1157 { 1158 <label for="@settings.Id">@settings.Label</label> 1159 } 1160 @if (!string.IsNullOrEmpty(settings.HelpText)) 1161 { 1162 <small class="form__help-text">@settings.HelpText</small> 1163 } 1164 1165 @if (settings.ActionButton != null) 1166 { 1167 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1168 <div class="form__field-combi u-no-margin dw-mod"> 1169 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1170 @Render(settings.ActionButton) 1171 </div> 1172 } 1173 else 1174 { 1175 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1176 } 1177 1178 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1179 </div> 1180 } 1181 @using System.Reflection 1182 @using Dynamicweb.Rapido.Blocks.Components.General 1183 @using Dynamicweb.Rapido.Blocks.Components 1184 1185 1186 @* Component *@ 1187 1188 @helper RenderTextareaField(TextareaField settings) 1189 { 1190 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1191 string id = settings.Id; 1192 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1193 { 1194 id = Guid.NewGuid().ToString("N"); 1195 } 1196 1197 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1198 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1199 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1200 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1201 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1202 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1203 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1204 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1205 if (settings.Required) { attributes.Add("required", "true"); } 1206 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1207 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1208 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1209 attributes.Add("name", settings.Name); 1210 1211 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1212 1213 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1214 @if (!string.IsNullOrEmpty(settings.Label)) 1215 { 1216 <label for="@id">@settings.Label</label> 1217 } 1218 @if (!string.IsNullOrEmpty(settings.HelpText)) 1219 { 1220 <small class="form__help-text">@settings.HelpText</small> 1221 } 1222 1223 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 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 RenderHiddenField(HiddenField settings) { 1236 var attributes = new Dictionary<string, string>(); 1237 attributes.Add("type", "hidden"); 1238 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1239 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1240 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1241 1242 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1243 } 1244 @using System.Reflection 1245 @using Dynamicweb.Rapido.Blocks.Components.General 1246 @using Dynamicweb.Rapido.Blocks.Components 1247 1248 @* Component *@ 1249 1250 @helper RenderCheckboxField(CheckboxField settings) 1251 { 1252 var attributes = new Dictionary<string, string>(); 1253 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1254 { 1255 settings.Id = Guid.NewGuid().ToString("N"); 1256 } 1257 1258 /*base settings*/ 1259 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1260 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1261 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1262 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1263 if (settings.Required) { attributes.Add("required", "true"); } 1264 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1265 /*end*/ 1266 1267 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1268 1269 attributes.Add("type", "checkbox"); 1270 if (settings.Checked) { attributes.Add("checked", "true"); } 1271 settings.CssClass = "form__control " + settings.CssClass; 1272 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1273 1274 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1275 1276 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1277 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1278 @if (!string.IsNullOrEmpty(settings.Label)) 1279 { 1280 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1281 } 1282 @if (!string.IsNullOrEmpty(settings.HelpText)) 1283 { 1284 <small class="form__help-text">@settings.HelpText</small> 1285 } 1286 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1287 </div> 1288 } 1289 @using System.Reflection 1290 @using Dynamicweb.Rapido.Blocks.Components.General 1291 @using Dynamicweb.Rapido.Blocks.Components 1292 1293 1294 @* Component *@ 1295 1296 @helper RenderCheckboxListField(CheckboxListField settings) 1297 { 1298 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1299 @if (!string.IsNullOrEmpty(settings.Label)) 1300 { 1301 <label>@settings.Label</label> 1302 } 1303 @if (!string.IsNullOrEmpty(settings.HelpText)) 1304 { 1305 <small class="form__help-text">@settings.HelpText</small> 1306 } 1307 1308 @foreach (var item in settings.Options) 1309 { 1310 if (settings.Required) 1311 { 1312 item.Required = true; 1313 } 1314 if (settings.Disabled) 1315 { 1316 item.Disabled = true; 1317 } 1318 if (!string.IsNullOrEmpty(settings.Name)) 1319 { 1320 item.Name = settings.Name; 1321 } 1322 if (!string.IsNullOrEmpty(settings.CssClass)) 1323 { 1324 item.CssClass += settings.CssClass; 1325 } 1326 1327 /* value is not supported */ 1328 1329 if (!string.IsNullOrEmpty(settings.OnClick)) 1330 { 1331 item.OnClick += settings.OnClick; 1332 } 1333 if (!string.IsNullOrEmpty(settings.OnChange)) 1334 { 1335 item.OnChange += settings.OnChange; 1336 } 1337 @Render(item) 1338 } 1339 1340 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1341 </div> 1342 } 1343 @using Dynamicweb.Rapido.Blocks.Components.General 1344 1345 @* Component *@ 1346 1347 @helper RenderSearch(Search settings) 1348 { 1349 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1350 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1351 1352 if (string.IsNullOrEmpty(settings.Id)) 1353 { 1354 settings.Id = Guid.NewGuid().ToString("N"); 1355 } 1356 1357 var resultAttributes = new Dictionary<string, string>(); 1358 1359 if (settings.PageSize != 0) 1360 { 1361 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1362 } 1363 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1364 { 1365 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1366 if (!string.IsNullOrEmpty(groupValue)) 1367 { 1368 resultAttributes.Add("data-selected-group", groupValue); 1369 } 1370 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1371 { 1372 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1373 } 1374 } 1375 resultAttributes.Add("data-force-init", "true"); 1376 if (settings.GoToFirstSearchResultOnEnter) 1377 { 1378 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1379 } 1380 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1381 { 1382 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1383 } 1384 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1385 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1386 1387 if (settings.SecondSearchData != null) 1388 { 1389 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1390 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1391 } 1392 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1393 { 1394 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1395 } 1396 1397 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1398 1399 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1400 1401 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1402 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1403 { 1404 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1405 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1406 } 1407 1408 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1409 1410 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1411 @if (settings.SecondSearchData != null) 1412 { 1413 <div class="search__column search__column--products dw-mod"> 1414 <div class="search__column-header dw-mod">@Translate("Products")</div> 1415 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1416 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1417 { 1418 @Render(new Link { 1419 Title = Translate("View all"), 1420 CssClass = "js-view-all-button u-margin", 1421 Href = settings.SearchData.ResultsPageUrl 1422 }); 1423 } 1424 </div> 1425 <div class="search__column search__column--pages dw-mod"> 1426 <div class="search__column-header">@Translate("Pages")</div> 1427 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1428 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1429 { 1430 @Render(new Link 1431 { 1432 Title = Translate("View all"), 1433 CssClass = "js-view-all-button u-margin", 1434 Href = settings.SecondSearchData.ResultsPageUrl 1435 }); 1436 } 1437 </div> 1438 } 1439 else 1440 { 1441 <div class="search__column search__column--only dw-mod"> 1442 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1443 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1444 { 1445 @Render(new Link { 1446 Title = Translate("View all"), 1447 CssClass = "js-view-all-button u-margin", 1448 Href = settings.SearchData.ResultsPageUrl 1449 }); 1450 } 1451 </div> 1452 } 1453 </div> 1454 1455 @if (settings.SearchButton != null) 1456 { 1457 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1458 if (settings.RenderDefaultSearchIcon) 1459 { 1460 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1461 } 1462 @Render(settings.SearchButton); 1463 } 1464 </div> 1465 } 1466 @using System.Reflection 1467 @using Dynamicweb.Rapido.Blocks.Components.General 1468 @using Dynamicweb.Rapido.Blocks.Components 1469 1470 1471 @* Component *@ 1472 1473 @helper RenderSelectField(SelectField settings) 1474 { 1475 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1476 { 1477 settings.Id = Guid.NewGuid().ToString("N"); 1478 } 1479 1480 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1481 @if (!string.IsNullOrEmpty(settings.Label)) 1482 { 1483 <label for="@settings.Id">@settings.Label</label> 1484 } 1485 @if (!string.IsNullOrEmpty(settings.HelpText)) 1486 { 1487 <small class="form__help-text">@settings.HelpText</small> 1488 } 1489 1490 @if (settings.ActionButton != null) 1491 { 1492 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1493 <div class="form__field-combi u-no-margin dw-mod"> 1494 @RenderSelectBase(settings) 1495 @Render(settings.ActionButton) 1496 </div> 1497 } 1498 else 1499 { 1500 @RenderSelectBase(settings) 1501 } 1502 1503 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1504 </div> 1505 } 1506 1507 @helper RenderSelectBase(SelectField settings) 1508 { 1509 var attributes = new Dictionary<string, string>(); 1510 1511 /*base settings*/ 1512 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1513 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1514 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1515 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1516 if (settings.Required) { attributes.Add("required", "true"); } 1517 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1518 /*end*/ 1519 1520 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1521 1522 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1523 @if (settings.Default != null) 1524 { 1525 @Render(settings.Default) 1526 } 1527 1528 @foreach (var item in settings.Options) 1529 { 1530 if (!string.IsNullOrEmpty(settings.Value)) { 1531 item.Checked = item.Value == settings.Value; 1532 } 1533 @Render(item) 1534 } 1535 </select> 1536 } 1537 @using System.Reflection 1538 @using Dynamicweb.Rapido.Blocks.Components.General 1539 @using Dynamicweb.Rapido.Blocks.Components 1540 1541 @* Component *@ 1542 1543 @helper RenderRadioButtonField(RadioButtonField settings) 1544 { 1545 var attributes = new Dictionary<string, string>(); 1546 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1547 { 1548 settings.Id = Guid.NewGuid().ToString("N"); 1549 } 1550 1551 /*base settings*/ 1552 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1553 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1554 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1555 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1556 if (settings.Required) { attributes.Add("required", "true"); } 1557 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1558 /*end*/ 1559 1560 attributes.Add("type", "radio"); 1561 if (settings.Checked) { attributes.Add("checked", "true"); } 1562 settings.CssClass = "form__control " + settings.CssClass; 1563 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1564 1565 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1566 1567 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1568 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1569 @if (!string.IsNullOrEmpty(settings.Label)) 1570 { 1571 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1572 } 1573 @if (!string.IsNullOrEmpty(settings.HelpText)) 1574 { 1575 <small class="form__help-text">@settings.HelpText</small> 1576 } 1577 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1578 </div> 1579 } 1580 @using System.Reflection 1581 @using Dynamicweb.Rapido.Blocks.Components.General 1582 @using Dynamicweb.Rapido.Blocks.Components 1583 1584 1585 @* Component *@ 1586 1587 @helper RenderRadioButtonListField(RadioButtonListField settings) 1588 { 1589 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1590 1591 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1592 @if (!string.IsNullOrEmpty(settings.Label)) 1593 { 1594 <label>@settings.Label</label> 1595 } 1596 @if (!string.IsNullOrEmpty(settings.HelpText)) 1597 { 1598 <small class="form__help-text">@settings.HelpText</small> 1599 } 1600 1601 @foreach (var item in settings.Options) 1602 { 1603 if (settings.Required) 1604 { 1605 item.Required = true; 1606 } 1607 if (settings.Disabled) 1608 { 1609 item.Disabled = true; 1610 } 1611 if (!string.IsNullOrEmpty(settings.Name)) 1612 { 1613 item.Name = settings.Name; 1614 } 1615 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1616 { 1617 item.Checked = true; 1618 } 1619 if (!string.IsNullOrEmpty(settings.OnClick)) 1620 { 1621 item.OnClick += settings.OnClick; 1622 } 1623 if (!string.IsNullOrEmpty(settings.OnChange)) 1624 { 1625 item.OnChange += settings.OnChange; 1626 } 1627 if (!string.IsNullOrEmpty(settings.CssClass)) 1628 { 1629 item.CssClass += settings.CssClass; 1630 } 1631 @Render(item) 1632 } 1633 1634 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1635 </div> 1636 } 1637 @using System.Reflection 1638 @using Dynamicweb.Rapido.Blocks.Components.General 1639 @using Dynamicweb.Rapido.Blocks.Components 1640 1641 1642 @* Component *@ 1643 1644 @helper RenderNotificationMessage(NotificationMessage settings) 1645 { 1646 if (!string.IsNullOrEmpty(settings.Message)) 1647 { 1648 var attributes = new Dictionary<string, string>(); 1649 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1650 1651 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1652 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1653 } 1654 } 1655 @using Dynamicweb.Rapido.Blocks.Components.General 1656 1657 1658 @* Component *@ 1659 1660 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1661 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1662 1663 <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> 1664 @if (settings.SubBlocks != null) { 1665 @RenderBlockList(settings.SubBlocks) 1666 } 1667 </div> 1668 } 1669 @using System.Reflection 1670 @using Dynamicweb.Rapido.Blocks.Components.General 1671 @using Dynamicweb.Rapido.Blocks.Components 1672 @using System.Text.RegularExpressions 1673 1674 1675 @* Component *@ 1676 1677 @helper RenderSticker(Sticker settings) { 1678 if (!String.IsNullOrEmpty(settings.Title)) { 1679 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1680 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1681 1682 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1683 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1684 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1685 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1686 optionalAttributes.Add("style", styleTag); 1687 } 1688 1689 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1690 } 1691 } 1692 1693 @using System.Reflection 1694 @using Dynamicweb.Rapido.Blocks.Components.General 1695 @using Dynamicweb.Rapido.Blocks.Components 1696 1697 1698 @* Component *@ 1699 1700 @helper RenderStickersCollection(StickersCollection settings) 1701 { 1702 if (settings.Stickers.Count > 0) 1703 { 1704 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1705 1706 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1707 @foreach (Sticker sticker in settings.Stickers) 1708 { 1709 @Render(sticker) 1710 } 1711 </div> 1712 } 1713 } 1714 1715 @using Dynamicweb.Rapido.Blocks.Components.General 1716 1717 1718 @* Component *@ 1719 1720 @helper RenderForm(Form settings) { 1721 if (settings != null) 1722 { 1723 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1724 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1725 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1726 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1727 var enctypes = new Dictionary<string, string> 1728 { 1729 { "multipart", "multipart/form-data" }, 1730 { "text", "text/plain" }, 1731 { "application", "application/x-www-form-urlencoded" } 1732 }; 1733 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1734 optionalAttributes.Add("method", settings.Method.ToString()); 1735 1736 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1737 { 1738 @settings.FormStartMarkup 1739 } 1740 else 1741 { 1742 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1743 } 1744 1745 foreach (var field in settings.GetFields()) 1746 { 1747 @Render(field) 1748 } 1749 1750 @:</form> 1751 } 1752 } 1753 @using System.Reflection 1754 @using Dynamicweb.Rapido.Blocks.Components.General 1755 @using Dynamicweb.Rapido.Blocks.Components 1756 1757 1758 @* Component *@ 1759 1760 @helper RenderText(Text settings) 1761 { 1762 @settings.Content 1763 } 1764 @using System.Reflection 1765 @using Dynamicweb.Rapido.Blocks.Components.General 1766 @using Dynamicweb.Rapido.Blocks.Components 1767 1768 1769 @* Component *@ 1770 1771 @helper RenderContentModule(ContentModule settings) { 1772 if (!string.IsNullOrEmpty(settings.Content)) 1773 { 1774 @settings.Content 1775 } 1776 } 1777 @using System.Reflection 1778 @using Dynamicweb.Rapido.Blocks.Components.General 1779 @using Dynamicweb.Rapido.Blocks.Components 1780 1781 1782 @* Component *@ 1783 1784 @helper RenderModal(Modal settings) { 1785 if (settings != null) 1786 { 1787 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1788 1789 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1790 1791 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1792 1793 <div class="modal-container"> 1794 @if (!settings.DisableDarkOverlay) 1795 { 1796 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1797 } 1798 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1799 @if (settings.Heading != null) 1800 { 1801 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1802 { 1803 <div class="modal__header"> 1804 @Render(settings.Heading) 1805 </div> 1806 } 1807 } 1808 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1809 @if (!string.IsNullOrEmpty(settings.BodyText)) 1810 { 1811 @settings.BodyText 1812 } 1813 @if (settings.BodyTemplate != null) 1814 { 1815 @settings.BodyTemplate 1816 } 1817 @{ 1818 var actions = settings.GetActions(); 1819 } 1820 </div> 1821 @if (actions.Length > 0) 1822 { 1823 <div class="modal__footer"> 1824 @foreach (var action in actions) 1825 { 1826 action.CssClass += " u-no-margin"; 1827 @Render(action) 1828 } 1829 </div> 1830 } 1831 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1832 </div> 1833 </div> 1834 } 1835 } 1836 @using Dynamicweb.Rapido.Blocks.Components.General 1837 1838 @* Component *@ 1839 1840 @helper RenderMediaListItem(MediaListItem settings) 1841 { 1842 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1843 @if (!string.IsNullOrEmpty(settings.Label)) 1844 { 1845 if (!string.IsNullOrEmpty(settings.Link)) 1846 { 1847 @Render(new Link 1848 { 1849 Href = settings.Link, 1850 CssClass = "media-list-item__sticker dw-mod", 1851 ButtonLayout = ButtonLayout.None, 1852 Title = settings.Label, 1853 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1854 }) 1855 } 1856 else if (!string.IsNullOrEmpty(settings.OnClick)) 1857 { 1858 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1859 <span class="u-uppercase">@settings.Label</span> 1860 </span> 1861 } 1862 else 1863 { 1864 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1865 <span class="u-uppercase">@settings.Label</span> 1866 </span> 1867 } 1868 } 1869 <div class="media-list-item__wrap"> 1870 <div class="media-list-item__info dw-mod"> 1871 <div class="media-list-item__header dw-mod"> 1872 @if (!string.IsNullOrEmpty(settings.Title)) 1873 { 1874 if (!string.IsNullOrEmpty(settings.Link)) 1875 { 1876 @Render(new Link 1877 { 1878 Href = settings.Link, 1879 CssClass = "media-list-item__name dw-mod", 1880 ButtonLayout = ButtonLayout.None, 1881 Title = settings.Title, 1882 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1883 }) 1884 } 1885 else if (!string.IsNullOrEmpty(settings.OnClick)) 1886 { 1887 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1888 } 1889 else 1890 { 1891 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1892 } 1893 } 1894 1895 @if (!string.IsNullOrEmpty(settings.Status)) 1896 { 1897 <div class="media-list-item__state dw-mod">@settings.Status</div> 1898 } 1899 </div> 1900 @{ 1901 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1902 } 1903 1904 @Render(settings.InfoTable) 1905 </div> 1906 <div class="media-list-item__actions dw-mod"> 1907 <div class="media-list-item__actions-list dw-mod"> 1908 @{ 1909 var actions = settings.GetActions(); 1910 1911 foreach (ButtonBase action in actions) 1912 { 1913 action.ButtonLayout = ButtonLayout.None; 1914 action.CssClass += " media-list-item__action link"; 1915 1916 @Render(action) 1917 } 1918 } 1919 </div> 1920 1921 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1922 { 1923 settings.SelectButton.CssClass += " u-no-margin"; 1924 1925 <div class="media-list-item__action-button"> 1926 @Render(settings.SelectButton) 1927 </div> 1928 } 1929 </div> 1930 </div> 1931 </div> 1932 } 1933 @using Dynamicweb.Rapido.Blocks.Components.General 1934 @using Dynamicweb.Rapido.Blocks.Components 1935 1936 @helper RenderTable(Table settings) 1937 { 1938 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1939 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1940 1941 var enumToClasses = new Dictionary<TableDesign, string> 1942 { 1943 { TableDesign.Clean, "table--clean" }, 1944 { TableDesign.Bordered, "table--bordered" }, 1945 { TableDesign.Striped, "table--striped" }, 1946 { TableDesign.Hover, "table--hover" }, 1947 { TableDesign.Compact, "table--compact" }, 1948 { TableDesign.Condensed, "table--condensed" }, 1949 { TableDesign.NoTopBorder, "table--no-top-border" } 1950 }; 1951 string tableDesignClass = ""; 1952 if (settings.Design != TableDesign.None) 1953 { 1954 tableDesignClass = enumToClasses[settings.Design]; 1955 } 1956 1957 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1958 1959 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1960 1961 <table @ComponentMethods.AddAttributes(resultAttributes)> 1962 @if (settings.Header != null) 1963 { 1964 <thead> 1965 @Render(settings.Header) 1966 </thead> 1967 } 1968 <tbody> 1969 @foreach (var row in settings.Rows) 1970 { 1971 @Render(row) 1972 } 1973 </tbody> 1974 @if (settings.Footer != null) 1975 { 1976 <tfoot> 1977 @Render(settings.Footer) 1978 </tfoot> 1979 } 1980 </table> 1981 } 1982 @using Dynamicweb.Rapido.Blocks.Components.General 1983 @using Dynamicweb.Rapido.Blocks.Components 1984 1985 @helper RenderTableRow(TableRow settings) 1986 { 1987 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1988 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1989 1990 var enumToClasses = new Dictionary<TableRowDesign, string> 1991 { 1992 { TableRowDesign.NoBorder, "table__row--no-border" }, 1993 { TableRowDesign.Border, "table__row--border" }, 1994 { TableRowDesign.TopBorder, "table__row--top-line" }, 1995 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1996 { TableRowDesign.Solid, "table__row--solid" } 1997 }; 1998 1999 string tableRowDesignClass = ""; 2000 if (settings.Design != TableRowDesign.None) 2001 { 2002 tableRowDesignClass = enumToClasses[settings.Design]; 2003 } 2004 2005 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2006 2007 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2008 2009 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2010 @foreach (var cell in settings.Cells) 2011 { 2012 if (settings.IsHeaderRow) 2013 { 2014 cell.IsHeader = true; 2015 } 2016 @Render(cell) 2017 } 2018 </tr> 2019 } 2020 @using Dynamicweb.Rapido.Blocks.Components.General 2021 @using Dynamicweb.Rapido.Blocks.Components 2022 @using Dynamicweb.Core 2023 2024 @helper RenderTableCell(TableCell settings) 2025 { 2026 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2027 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2028 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2029 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2030 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2031 2032 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2033 2034 string tagName = settings.IsHeader ? "th" : "td"; 2035 2036 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2037 @settings.Content 2038 @("</" + tagName + ">"); 2039 } 2040 @using System.Linq 2041 @using Dynamicweb.Rapido.Blocks.Components.General 2042 2043 @* Component *@ 2044 2045 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2046 { 2047 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2048 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2049 2050 if (settings.NumberOfPages > 1) 2051 { 2052 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2053 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2054 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2055 2056 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2057 @if (settings.ShowPagingInfo) 2058 { 2059 <div class="pager__info dw-mod"> 2060 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2061 </div> 2062 } 2063 <ul class="pager__list dw-mod"> 2064 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2065 { 2066 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2067 } 2068 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2069 { 2070 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2071 } 2072 @if (settings.GetPages().Any()) 2073 { 2074 foreach (var page in settings.GetPages()) 2075 { 2076 @Render(page) 2077 } 2078 } 2079 else 2080 { 2081 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2082 { 2083 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2084 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2085 } 2086 } 2087 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2088 { 2089 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2090 } 2091 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2092 { 2093 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2094 } 2095 </ul> 2096 </div> 2097 } 2098 } 2099 2100 @helper RenderPaginationItem(PaginationItem settings) 2101 { 2102 if (settings.Icon == null) 2103 { 2104 settings.Icon = new Icon(); 2105 } 2106 2107 settings.Icon.Label = settings.Label; 2108 <li class="pager__btn dw-mod"> 2109 @if (settings.IsActive) 2110 { 2111 <span class="pager__num pager__num--current dw-mod"> 2112 @Render(settings.Icon) 2113 </span> 2114 } 2115 else 2116 { 2117 <a href="@settings.Link" class="pager__num dw-mod"> 2118 @Render(settings.Icon) 2119 </a> 2120 } 2121 </li> 2122 } 2123 2124 2125 @using Dynamicweb.Rapido.Blocks.Components.General 2126 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2127 2128 2129 @using Dynamicweb.Frontend 2130 @using System.Reflection 2131 @using Dynamicweb.Content.Items 2132 @using System.Web.UI.HtmlControls 2133 @using Dynamicweb.Rapido.Blocks.Components 2134 @using Dynamicweb.Rapido.Blocks 2135 @using Dynamicweb.Rapido.Blocks.Components.Articles 2136 2137 @* Components for the articles *@ 2138 @using System.Reflection 2139 @using Dynamicweb.Rapido.Blocks.Components.Articles 2140 2141 2142 @* Component for the articles *@ 2143 2144 @helper RenderArticleBanner(dynamic settings) { 2145 string filterClasses = "image-filter image-filter--darken"; 2146 settings.Layout = ArticleHeaderLayout.Banner; 2147 2148 if (settings.Image != null) 2149 { 2150 if (settings.Image.Path != null) 2151 { 2152 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2153 <div class="background-image @filterClasses dw-mod"> 2154 <div class="background-image__wrapper @filterClasses dw-mod"> 2155 @{ 2156 settings.Image.CssClass += "background-image__cover dw-mod"; 2157 } 2158 @Render(settings.Image) 2159 </div> 2160 </div> 2161 <div class="center-container dw-mod"> 2162 <div class="grid"> 2163 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg"> 2164 <div class="u-left-middle"> 2165 <div> 2166 @if (!String.IsNullOrEmpty(settings.Heading)) 2167 { 2168 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2169 } 2170 @if (!String.IsNullOrEmpty(settings.Subheading)) 2171 { 2172 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2173 } 2174 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2175 { 2176 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2177 } 2178 @if (!String.IsNullOrEmpty(settings.Link)) { 2179 <div class="grid__cell"> 2180 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2181 </div> 2182 } 2183 </div> 2184 </div> 2185 </div> 2186 @if (settings.ExternalParagraphId != 0) 2187 { 2188 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod"> 2189 <div class="u-color-light-gray--bg u-color-dark dw-mod"> 2190 @RenderParagraphContent(settings.ExternalParagraphId) 2191 </div> 2192 </div> 2193 } 2194 2195 </div> 2196 </div> 2197 </section> 2198 if (!String.IsNullOrEmpty(settings.Image.Caption)) { 2199 <div class="image-caption dw-mod">@settings.Image.Caption</div> 2200 } 2201 } 2202 else 2203 { 2204 settings.Layout = ArticleHeaderLayout.Clean; 2205 @RenderArticleCleanHeader(settings); 2206 } 2207 } 2208 else 2209 { 2210 settings.Layout = ArticleHeaderLayout.Clean; 2211 @RenderArticleCleanHeader(settings); 2212 } 2213 } 2214 @using System.Reflection 2215 @using Dynamicweb.Rapido.Blocks.Components 2216 @using Dynamicweb.Rapido.Blocks.Components.General 2217 @using Dynamicweb.Rapido.Blocks.Components.Articles 2218 @using Dynamicweb.Rapido.Blocks 2219 2220 2221 @* Component for the articles *@ 2222 2223 @helper RenderArticleHeader(ArticleHeader settings) { 2224 dynamic[] methodParameters = new dynamic[1]; 2225 methodParameters[0] = settings; 2226 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleHeaderCustom"); 2227 2228 if (customMethod != null) 2229 { 2230 @customMethod.Invoke(this, methodParameters).ToString(); 2231 } else { 2232 switch (settings.Layout) 2233 { 2234 case ArticleHeaderLayout.Clean: 2235 @RenderArticleCleanHeader(settings); 2236 break; 2237 case ArticleHeaderLayout.Split: 2238 @RenderArticleSplitHeader(settings); 2239 break; 2240 case ArticleHeaderLayout.Banner: 2241 @RenderArticleBannerHeader(settings); 2242 break; 2243 case ArticleHeaderLayout.Overlay: 2244 @RenderArticleOverlayHeader(settings); 2245 break; 2246 default: 2247 @RenderArticleCleanHeader(settings); 2248 break; 2249 } 2250 } 2251 } 2252 2253 @helper RenderArticleCleanHeader(ArticleHeader settings) { 2254 dynamic[] methodParameters = new dynamic[1]; 2255 methodParameters[0] = settings; 2256 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleCleanHeaderCustom"); 2257 2258 if (customMethod != null) 2259 { 2260 @customMethod.Invoke(this, methodParameters).ToString(); 2261 } 2262 else 2263 { 2264 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2265 2266 <div class="grid grid--align-content-start grid--justify-start"> 2267 <div class="grid__col-md-@contentColumns grid__col-sm-12 u-padding--lg dw-mod"> 2268 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0) 2269 { 2270 <div class="u-border-bottom u-padding-bottom"> 2271 @if (!String.IsNullOrEmpty(settings.Category)) 2272 { 2273 <div class="u-pull--left"> 2274 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2275 </div> 2276 } 2277 <div class="u-pull--right"> 2278 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2279 { 2280 <small class="article__post-info dw-mod">@settings.Author @settings.Date</small> 2281 } 2282 @if (settings.RatingOutOf != 0) 2283 { 2284 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2285 } 2286 </div> 2287 </div> 2288 } 2289 2290 <div class="grid__cell"> 2291 @if (!String.IsNullOrEmpty(settings.Heading)) 2292 { 2293 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2294 } 2295 @if (settings.Image != null) 2296 { 2297 if (settings.Image.Path != null) 2298 { 2299 <div class="u-padding-bottom--lg"> 2300 @Render(settings.Image) 2301 </div> 2302 } 2303 } 2304 @if (!String.IsNullOrEmpty(settings.Subheading)) 2305 { 2306 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2307 } 2308 @if (!String.IsNullOrEmpty(settings.Link)) 2309 { 2310 <div class="grid__cell"> 2311 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2312 </div> 2313 } 2314 </div> 2315 </div> 2316 @if (settings.ExternalParagraphId != 0) 2317 { 2318 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod"> 2319 @RenderParagraphContent(settings.ExternalParagraphId) 2320 </div> 2321 } 2322 </div> 2323 } 2324 } 2325 2326 @helper RenderArticleSplitHeader(ArticleHeader settings) { 2327 dynamic[] methodParameters = new dynamic[1]; 2328 methodParameters[0] = settings; 2329 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleSplitHeaderCustom"); 2330 2331 if (customMethod != null) 2332 { 2333 @customMethod.Invoke(this, methodParameters).ToString(); 2334 } 2335 else 2336 { 2337 string headerColumnWidth = settings.ExternalParagraphId != 0 ? "4" : "6"; 2338 2339 if (settings.Image != null) 2340 { 2341 if (settings.Image.Path != null) 2342 { 2343 <section class="multiple-paragraphs-container paragraph-container--full-width"> 2344 <div class="grid"> 2345 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod"> 2346 <div class="u-left-middle u-padding--lg"> 2347 <div> 2348 @if (!String.IsNullOrEmpty(settings.Category)) 2349 { 2350 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2351 } 2352 @if (!String.IsNullOrEmpty(settings.Heading)) 2353 { 2354 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2355 } 2356 @if (!String.IsNullOrEmpty(settings.Subheading)) 2357 { 2358 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2359 } 2360 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2361 { 2362 <small class="article__post-info u-pull--left dw-mod">@settings.Author @settings.Date</small> 2363 } 2364 @if (settings.RatingOutOf != 0) 2365 { 2366 <div class="u-pull--right"> 2367 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2368 </div> 2369 } 2370 @if (!String.IsNullOrEmpty(settings.Link)) { 2371 <div class="u-full-width u-pull--left u-margin-top"> 2372 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2373 </div> 2374 } 2375 </div> 2376 </div> 2377 </div> 2378 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod" style="background-image:url(/Admin/Public/GetImage.ashx?width=1800&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=@settings.Image.Path); background-position: center center; background-size: cover;"></div> 2379 @if (settings.ExternalParagraphId != 0) 2380 { 2381 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto u-color-light-gray--bg dw-mod"> 2382 @RenderParagraphContent(settings.ExternalParagraphId) 2383 </div> 2384 } 2385 </div> 2386 </section> 2387 } 2388 } 2389 else 2390 { 2391 @RenderArticleCleanHeader(settings); 2392 } 2393 } 2394 } 2395 2396 @helper RenderArticleOverlayHeader(ArticleHeader settings) { 2397 dynamic[] methodParameters = new dynamic[1]; 2398 methodParameters[0] = settings; 2399 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleOverlayHeaderCustom"); 2400 2401 if (customMethod != null) 2402 { 2403 @customMethod.Invoke(this, methodParameters).ToString(); 2404 } 2405 else 2406 { 2407 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2408 string contentAlignment = settings.TextLayout == ArticleHeaderTextLayout.Center ? "grid--justify-center" : ""; 2409 2410 if (settings.Image != null) 2411 { 2412 if (settings.Image.Path != null) 2413 { 2414 if (settings.ExternalParagraphId == 0) 2415 { 2416 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2417 <div class="background-image image-filter image-filter--darken dw-mod"> 2418 <div class="background-image__wrapper image-filter image-filter--darken dw-mod"> 2419 @{ 2420 settings.Image.CssClass += "background-image__cover dw-mod"; 2421 } 2422 @Render(settings.Image) 2423 </div> 2424 </div> 2425 <div class="center-container dw-mod"> 2426 <div class="grid @contentAlignment"> 2427 <div class="grid__col-md-@contentColumns grid__col-xs-12 paragraph-container paragraph-container--height-xl u-no-padding dw-mod"> 2428 @if (!String.IsNullOrEmpty(settings.Heading)) 2429 { 2430 <h1 class="article__header article__header--giant u-padding-top--lg dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2431 } 2432 @if (!String.IsNullOrEmpty(settings.Subheading)) 2433 { 2434 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2435 } 2436 <div class="u-margin-top"> 2437 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2438 { 2439 <small class="article__post-info u-pull--left dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2440 } 2441 @if (settings.RatingOutOf != 0) 2442 { 2443 <div class="u-pull--right"> 2444 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2445 </div> 2446 } 2447 </div> 2448 @if (!String.IsNullOrEmpty(settings.Link)) 2449 { 2450 <div class="grid__cell"> 2451 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2452 </div> 2453 } 2454 </div> 2455 </div> 2456 </div> 2457 </section> 2458 } 2459 else 2460 { 2461 @RenderArticleBanner(settings); 2462 } 2463 } 2464 } 2465 else 2466 { 2467 @RenderArticleCleanHeader(settings); 2468 } 2469 } 2470 } 2471 2472 @helper RenderArticleBannerHeader(dynamic settings) { 2473 dynamic[] methodParameters = new dynamic[1]; 2474 methodParameters[0] = settings; 2475 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleBannerHeaderCustom"); 2476 2477 if (customMethod != null) 2478 { 2479 @customMethod.Invoke(this, methodParameters).ToString(); 2480 } 2481 else 2482 { 2483 @RenderArticleBanner(settings); 2484 } 2485 } 2486 @using System.Reflection 2487 @using System.Text.RegularExpressions; 2488 @using Dynamicweb.Frontend 2489 @using Dynamicweb.Content.Items 2490 @using Dynamicweb.Rapido.Blocks.Components 2491 @using Dynamicweb.Rapido.Blocks.Components.Articles 2492 @using Dynamicweb.Rapido.Blocks 2493 2494 @* Component for the articles *@ 2495 2496 @helper RenderArticleBodyRow(ArticleBodyRow settings) 2497 { 2498 string position = settings.TopLayout == "overlay" ? "article__overlay-offset" : ""; 2499 string contentAlignment = settings.TextLayout == "center" ? "grid--justify-center" : ""; 2500 2501 <div class="grid grid--align-content-start @contentAlignment @position dw-mod"> 2502 @RenderBlockList(settings.SubBlocks) 2503 </div> 2504 } 2505 @using System.Reflection 2506 @using Dynamicweb.Rapido.Blocks.Components 2507 @using Dynamicweb.Rapido.Blocks.Components.General 2508 @using Dynamicweb.Rapido.Blocks.Components.Articles 2509 @using Dynamicweb.Rapido.Blocks 2510 2511 @* Component for the articles *@ 2512 2513 @helper RenderArticleImage(ArticleImage settings) 2514 { 2515 if (settings.Image != null) 2516 { 2517 if (settings.Image.Path != null) 2518 { 2519 <div class="u-margin-bottom--lg"> 2520 @Render(settings.Image) 2521 </div> 2522 } 2523 } 2524 } 2525 @using System.Reflection 2526 @using Dynamicweb.Rapido.Blocks.Components 2527 @using Dynamicweb.Rapido.Blocks.Components.Articles 2528 2529 2530 @* Component for the articles *@ 2531 2532 @helper RenderArticleSubHeader(ArticleSubHeader settings) 2533 { 2534 if (!String.IsNullOrEmpty(settings.Title)) 2535 { 2536 <h2 class="article__header">@settings.Title</h2> 2537 } 2538 } 2539 @using System.Reflection 2540 @using Dynamicweb.Rapido.Blocks.Components 2541 @using Dynamicweb.Rapido.Blocks.Components.Articles 2542 @using Dynamicweb.Rapido.Blocks 2543 2544 2545 @* Component for the articles *@ 2546 2547 @helper RenderArticleText(ArticleText settings) 2548 { 2549 if (!String.IsNullOrEmpty(settings.Text)) 2550 { 2551 string greatTextClass = settings.EnableLargeText == true ? "article__paragraph--great-text" : ""; 2552 2553 <div class="article__paragraph @greatTextClass"> 2554 @settings.Text 2555 </div> 2556 } 2557 } 2558 @using System.Reflection 2559 @using Dynamicweb.Rapido.Blocks.Components 2560 @using Dynamicweb.Rapido.Blocks.Components.Articles 2561 @using Dynamicweb.Rapido.Blocks 2562 2563 2564 @* Component for the articles *@ 2565 2566 @helper RenderArticleQuote(ArticleQuote settings) 2567 { 2568 string text = Regex.Replace(settings.Text, "<.*?>", String.Empty); 2569 2570 <div class="grid u-padding-bottom--lg"> 2571 @if (settings.Image != null) 2572 { 2573 if (settings.Image.Path != null) { 2574 <div class="grid__col-3"> 2575 <div class="grid__cell-img"> 2576 @{ 2577 settings.Image.Title = !String.IsNullOrEmpty(settings.Image.Title) ? settings.Image.Title : settings.Author; 2578 settings.Image.CssClass += " article__image article__image--ball"; 2579 settings.Image.ImageDefault.Width = 200; 2580 settings.Image.ImageDefault.Height = 200; 2581 } 2582 @Render(settings.Image) 2583 </div> 2584 </div> 2585 } 2586 } 2587 <div class="grid__col-auto"> 2588 @if (!String.IsNullOrEmpty(settings.Text)) 2589 { 2590 <div class="article__quote dw-mod"> 2591 <i class="fas fa-quote-right u-margin-bottom--lg"></i> 2592 @settings.Text 2593 <i class="fas fa-quote-right"></i> 2594 </div> 2595 } 2596 @if (!String.IsNullOrEmpty(settings.Author)) 2597 { 2598 <div class="article__quote-author dw-mod"> 2599 - @settings.Author 2600 </div> 2601 } 2602 </div> 2603 </div> 2604 } 2605 @using System.Reflection 2606 @using Dynamicweb.Rapido.Blocks.Components 2607 @using Dynamicweb.Rapido.Blocks.Components.Articles 2608 @using Dynamicweb.Rapido.Blocks 2609 2610 @* Component for the articles *@ 2611 2612 @helper RenderArticleInfoTable(ArticleInfoTable settings) 2613 { 2614 <table class="table table--clean"> 2615 @foreach (var row in settings.Rows) 2616 { 2617 string iconColor = row.IconColor != null ? row.IconColor : "u-brand-color-two"; 2618 2619 <tr> 2620 @if (!String.IsNullOrEmpty(row.Icon)) 2621 { 2622 <td class="u-w32px"><i class="@row.Icon fa-2x @row.IconColor"></i></td> 2623 } 2624 <td class="u-no-margin-on-p-elements"> 2625 <div class="u-bold">@row.Title</div> 2626 @if (!String.IsNullOrEmpty(row.SubTitle)) 2627 { 2628 if (row.Link == null) 2629 { 2630 <div>@row.SubTitle</div> 2631 } 2632 else 2633 { 2634 <a href="@row.Link" class="u-color-inherit">@row.SubTitle</a> 2635 } 2636 } 2637 </td> 2638 </tr> 2639 } 2640 </table> 2641 } 2642 @using System.Reflection 2643 @using Dynamicweb.Rapido.Blocks.Components 2644 @using Dynamicweb.Rapido.Blocks.Components.General 2645 @using Dynamicweb.Rapido.Blocks.Components.Articles 2646 @using Dynamicweb.Rapido.Blocks 2647 2648 @* Component for the articles *@ 2649 2650 @helper RenderArticleGalleryModal(ArticleGalleryModal settings) 2651 { 2652 Modal galleryModal = new Modal 2653 { 2654 Id = "ParagraphGallery", 2655 Width = ModalWidth.Full, 2656 BodyTemplate = RenderArticleGalleryModalContent() 2657 }; 2658 2659 @Render(galleryModal) 2660 } 2661 2662 @helper RenderArticleGalleryModalContent() { 2663 <div class="modal__image-min-size-wrapper"> 2664 @Render(new Image { 2665 Id = "ParagraphGallery", 2666 Path = "#", 2667 CssClass = "modal--full__img", 2668 DisableLazyLoad = true, 2669 DisableImageEngine = true 2670 }) 2671 </div> 2672 2673 <div class="modal__images-counter" id="ParagraphGallery_counter"></div> 2674 2675 @Render(new Button { 2676 Id = "ParagraphGallery_prev", 2677 ButtonType = ButtonType.Button, 2678 ButtonLayout = ButtonLayout.None, 2679 CssClass = "modal__prev-btn", 2680 Icon = new Icon { Prefix = "far", Name = "fa-angle-left", LabelPosition = IconLabelPosition.After }, 2681 OnClick = "Gallery.prevImage('ParagraphGallery')" 2682 }) 2683 2684 @Render(new Button { 2685 Id = "ParagraphGallery_next", 2686 ButtonType = ButtonType.Button, 2687 ButtonLayout = ButtonLayout.None, 2688 CssClass = "modal__next-btn", 2689 Icon = new Icon { Prefix = "far", Name = "fa-angle-right", LabelPosition = IconLabelPosition.After }, 2690 OnClick = "Gallery.nextImage('ParagraphGallery')" 2691 }) 2692 } 2693 @using System.Reflection 2694 @using Dynamicweb.Rapido.Blocks.Components 2695 @using Dynamicweb.Rapido.Blocks.Components.Articles 2696 @using Dynamicweb.Rapido.Blocks 2697 2698 2699 @* Component for the articles *@ 2700 2701 @helper RenderArticleRelated(ArticleRelated settings) 2702 { 2703 string cardClass = Pageview.Device.ToString() != "Tablet" ? "card u-color-light--bg u-full-height" : ""; 2704 string cardFooterClass = Pageview.Device.ToString() != "Tablet" ? "card-footer u-color-light--bg" : ""; 2705 2706 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 2707 <div class="center-container dw-mod"> 2708 <div class="grid u-padding"> 2709 <div class="grid__col-md-12 grid__col-xs-12"> 2710 <h2 class="article__header u-no-margin u-margin-top">@settings.Title</h2> 2711 </div> 2712 </div> 2713 2714 <div class="js-handlebars-root u-padding" id="@settings.Title.Replace(" ", String.Empty)" data-template="RelatedSimpleTemplate" data-json-feed="/Default.aspx?ID=@settings.FeedPageId&@settings.Query&ExcludeItemID=@settings.CurrentPageId&PageSize=@settings.PageSize"></div> 2715 2716 <script id="RelatedSimpleTemplate" type="text/x-template"> 2717 {{#.}} 2718 <div class="grid u-padding-bottom--lg"> 2719 {{#Cases}} 2720 <div class="grid__col-lg-3 grid__col-sm-6 image-hover--zoom dw-mod"> 2721 <a href="{{link}}" class="u-full-height u-color-light--bg"> 2722 {{#if image}} 2723 <div class="u-color-light--bg u-no-padding dw-mod"> 2724 <div class="flex-img image-hover__wrapper"> 2725 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=680&height=314&amp;crop=1&amp;DoNotUpscale=True&amp;Compression=75&amp;image={{image}}" alt="{{title}}" /> 2726 </div> 2727 </div> 2728 {{/if}} 2729 2730 <div class="card u-color-light--bg dw-mod"> 2731 <h3 class="article-list__item-header u-truncate-text dw-mod">{{title}}</h3> 2732 <p class="article__short-summary dw-mod">{{summary}}</p> 2733 </div> 2734 </a> 2735 </div> 2736 {{/Cases}} 2737 </div> 2738 {{/.}} 2739 </script> 2740 </div> 2741 </section> 2742 } 2743 @using System.Reflection 2744 @using Dynamicweb.Rapido.Blocks.Components 2745 @using Dynamicweb.Rapido.Blocks.Components.Articles 2746 @using Dynamicweb.Rapido.Blocks 2747 2748 2749 @* Component for the articles *@ 2750 2751 @helper RenderArticleMenu(ArticleMenu settings) 2752 { 2753 if (!String.IsNullOrEmpty(settings.Title)) { 2754 <div class="u-margin u-border-bottom"> 2755 <h3 class="u-no-margin">@settings.Title</h3> 2756 </div> 2757 } 2758 2759 <ul class="menu-left u-margin-bottom dw-mod"> 2760 @foreach (var item in settings.Items) 2761 { 2762 @Render(item) 2763 } 2764 </ul> 2765 } 2766 2767 @helper RenderArticleMenuItem(ArticleMenuItem settings) 2768 { 2769 string link = !String.IsNullOrEmpty(settings.Link) ? settings.Link : "#"; 2770 2771 if (!String.IsNullOrEmpty(settings.Title)) { 2772 <li class="menu-left__item dw-mod"> 2773 <a href="@link" onclick="@settings.OnClick" class="menu-left__link dw-mod">@settings.Title</a> 2774 </li> 2775 } 2776 } 2777 @using System.Reflection 2778 @using Dynamicweb.Rapido.Blocks.Components 2779 @using Dynamicweb.Rapido.Blocks.Components.Articles 2780 @using Dynamicweb.Rapido.Blocks 2781 2782 @* Component for the articles *@ 2783 2784 @helper RenderArticleList(ArticleList settings) 2785 { 2786 if (Pageview != null) 2787 { 2788 bool isParagraph = Pageview.CurrentParagraph != null ? true : false; 2789 string[] sortArticlesListBy = new string[2]; 2790 2791 if (isParagraph) { 2792 sortArticlesListBy = Pageview.CurrentParagraph.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString()) ? Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2793 } 2794 else { 2795 sortArticlesListBy = Pageview.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.Item["SortArticlesListBy"].ToString()) ? Pageview.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2796 } 2797 2798 string sourcePage = settings.SourcePage != null ? settings.SourcePage : Pageview.ID.ToString(); 2799 2800 if (!settings.DisablePagination) { 2801 @RenderItemList(new 2802 { 2803 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2804 ListSourceType = settings.SourceType, 2805 ListSourcePage = sourcePage, 2806 ItemFieldsList = "*", 2807 Filter = settings.Filter, 2808 ListOrderBy = sortArticlesListBy[0], 2809 ListOrderByDirection = sortArticlesListBy[1], 2810 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2811 ListSecondOrderByDirection = "ASC", 2812 IncludeAllChildItems = true, 2813 ListTemplate = settings.Template, 2814 ListPageSize = settings.PageSize.ToString() 2815 }); 2816 } else { 2817 @RenderItemList(new 2818 { 2819 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2820 ListSourceType = settings.SourceType, 2821 ListSourcePage = sourcePage, 2822 ItemFieldsList = "*", 2823 Filter = settings.Filter, 2824 ListOrderBy = sortArticlesListBy[0], 2825 ListOrderByDirection = sortArticlesListBy[1], 2826 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2827 ListSecondOrderByDirection = "ASC", 2828 IncludeAllChildItems = true, 2829 ListTemplate = settings.Template, 2830 ListPageSize = settings.PageSize.ToString(), 2831 ListViewMode = "Partial", 2832 ListShowTo = settings.PageSize + 1 2833 }); 2834 } 2835 } 2836 } 2837 @using System.Reflection 2838 @using Dynamicweb.Rapido.Blocks.Components.Articles 2839 2840 2841 @* Component for the articles *@ 2842 2843 @helper RenderArticleSummary(ArticleSummary settings) 2844 { 2845 if (!String.IsNullOrEmpty(settings.Text)) 2846 { 2847 <div class="article__summary dw-mod">@settings.Text</div> 2848 } 2849 } 2850 @using System.Reflection 2851 @using Dynamicweb.Rapido.Blocks.Components 2852 @using Dynamicweb.Rapido.Blocks.Components.Articles 2853 @using Dynamicweb.Rapido.Blocks 2854 2855 @* Component for the articles *@ 2856 2857 @helper RenderArticleListCategoryFilter(ArticleListCategoryFilter settings) 2858 { 2859 string pageId = Pageview.ID.ToString(); 2860 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("sourcePage")) ? HttpContext.Current.Request.QueryString.Get("sourcePage") : Translate("All"); 2861 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 2862 2863 foreach (var option in settings.Categories) 2864 { 2865 selectedFilter = selectedFilter == option.Value ? option.Key : selectedFilter; 2866 } 2867 2868 if (selectedFilter == pageId) 2869 { 2870 selectedFilter = Translate("All"); 2871 } 2872 2873 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 2874 { 2875 <div class="u-pull--right u-margin-left"> 2876 <div class="collection u-no-margin"> 2877 <h5>@Translate("Category")</h5> 2878 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 2879 <div class="dropdown u-w180px dw-mod"> 2880 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 2881 <div class="dropdown__content dw-mod"> 2882 @foreach (var option in settings.Categories) 2883 { 2884 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 2885 } 2886 </div> 2887 <label class="dropdown-trigger-off" for="CategorySelector"></label> 2888 </div> 2889 </div> 2890 </div> 2891 } 2892 else 2893 { 2894 <div class="u-full-width u-margin-bottom"> 2895 <h5 class="u-no-margin">@Translate("Category")</h5> 2896 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 2897 <div class="dropdown u-full-width dw-mod"> 2898 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 2899 <div class="dropdown__content dw-mod"> 2900 @foreach (var option in settings.Categories) 2901 { 2902 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 2903 } 2904 </div> 2905 <label class="dropdown-trigger-off" for="CategorySelector"></label> 2906 </div> 2907 </div> 2908 } 2909 } 2910 @using System.Reflection 2911 @using Dynamicweb.Rapido.Blocks.Components 2912 @using Dynamicweb.Rapido.Blocks.Components.Articles 2913 @using Dynamicweb.Rapido.Blocks 2914 @using System.Collections.Generic 2915 2916 @* Component for the articles *@ 2917 2918 @helper RenderArticleListFilter(ArticleListFilter settings) 2919 { 2920 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get(settings.SystemName)) ? HttpContext.Current.Request.QueryString.Get(settings.SystemName) : Translate("All"); 2921 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 2922 2923 if (settings.Options != null) 2924 { 2925 if (settings.Options is IEnumerable<dynamic>) 2926 { 2927 var options = (IEnumerable<dynamic>) settings.Options; 2928 settings.Options = options.OrderBy(item => item.Name); 2929 } 2930 2931 foreach (var option in settings.Options) 2932 { 2933 selectedFilter = selectedFilter == option.Value ? option.Name : selectedFilter; 2934 } 2935 2936 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 2937 { 2938 <div class="u-pull--right u-margin-left"> 2939 <div class="collection u-no-margin"> 2940 <h5>@settings.Label</h5> 2941 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 2942 <div class="dropdown u-w180px dw-mod"> 2943 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 2944 <div class="dropdown__content dw-mod"> 2945 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 2946 @foreach (var option in settings.Options) 2947 { 2948 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 2949 } 2950 </div> 2951 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 2952 </div> 2953 </div> 2954 </div> 2955 } 2956 else 2957 { 2958 <div class="u-full-width u-margin-bottom"> 2959 <h5 class="u-no-margin">@settings.Label</h5> 2960 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 2961 <div class="dropdown u-full-width w-mod"> 2962 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 2963 <div class="dropdown__content dw-mod"> 2964 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 2965 @foreach (var option in settings.Options) 2966 { 2967 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 2968 } 2969 </div> 2970 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 2971 </div> 2972 </div> 2973 } 2974 } 2975 } 2976 @using System.Reflection 2977 @using Dynamicweb.Rapido.Blocks.Components 2978 @using Dynamicweb.Rapido.Blocks.Components.Articles 2979 @using Dynamicweb.Rapido.Blocks 2980 2981 @* Component for the articles *@ 2982 2983 @helper RenderArticleListSearch(ArticleListSearch settings) 2984 { 2985 string searchParameter = !string.IsNullOrEmpty(settings.SearchParameter) ? settings.SearchParameter : "Title"; 2986 string searchWord = HttpContext.Current.Request.QueryString.Get(searchParameter); 2987 string searchString = !string.IsNullOrEmpty(searchWord) ? searchWord.Trim('*') : ""; 2988 string className = "u-w340px u-pull--right u-margin-left"; 2989 2990 if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 2991 { 2992 className = "u-full-width"; 2993 } 2994 2995 <div class="typeahead u-color-inherit u-margin-bottom dw-mod @className"> 2996 <input type="text" class="typeahead-search-field u-no-margin dw-mod" placeholder="@Translate("Search in list")" value="@searchString" id="ArticleListSearchInput" onchange="QueryArray.setParameterInCurrentURL('@searchParameter', '*' + document.getElementById('ArticleListSearchInput').value + '*')"> 2997 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod"><i class="fas fa-search"></i></button> 2998 </div> 2999 } 3000 @using System.Reflection 3001 @using Dynamicweb.Rapido.Blocks.Components 3002 @using Dynamicweb.Rapido.Blocks.Components.Articles 3003 @using Dynamicweb.Rapido.Blocks 3004 3005 @* Component for the articles *@ 3006 3007 @helper RenderArticleListNoResultsInfo(ArticleListNoResultsInfo settings) 3008 { 3009 <div class="u-margin-top--lg u-bold u-ta-center u-bold">@Translate(settings.Message)</div> 3010 } 3011 @using System.Reflection 3012 @using Dynamicweb.Rapido.Blocks.Components 3013 @using Dynamicweb.Rapido.Blocks.Components.General 3014 @using Dynamicweb.Rapido.Blocks.Components.Articles 3015 @using Dynamicweb.Rapido.Blocks 3016 @using System.Text.RegularExpressions 3017 3018 @* Component for the articles *@ 3019 3020 @helper RenderArticleListItem(ArticleListItem settings) 3021 { 3022 switch (settings.Type) { 3023 case ArticleListItemType.Card: 3024 @RenderArticleListItemCard(settings); 3025 break; 3026 case ArticleListItemType.List: 3027 @RenderArticleListItemList(settings); 3028 break; 3029 case ArticleListItemType.Simple: 3030 @RenderArticleListItemSimple(settings); 3031 break; 3032 default: 3033 @RenderArticleListItemCard(settings); 3034 break; 3035 } 3036 } 3037 3038 @helper RenderArticleListItemCard(ArticleListItem settings) { 3039 <a href="@settings.Link" class="u-full-height u-color-light--bg"> 3040 <div class="u-color-light--bg u-no-padding dw-mod"> 3041 @if (settings.Logo != null) 3042 { 3043 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 3044 settings.Logo.ImageDefault.Crop = 5; 3045 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 3046 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 3047 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 3048 @if (settings.Stickers != null) 3049 { 3050 if (settings.Stickers.Position != StickersListPosition.Custom) 3051 { 3052 @Render(settings.Stickers); 3053 } 3054 } 3055 @RenderImage(settings.Logo) 3056 </div> 3057 } else if (settings.Image != null) 3058 { 3059 <div class="flex-img image-hover__wrapper u-position-relative dw-mod"> 3060 @if (settings.Stickers != null) 3061 { 3062 if (settings.Stickers.Position != StickersListPosition.Custom) 3063 { 3064 @Render(settings.Stickers); 3065 } 3066 } 3067 @Render(settings.Image) 3068 </div> 3069 } 3070 </div> 3071 3072 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 3073 { 3074 <div class="card u-color-light--bg dw-mod"> 3075 @if (settings.Stickers != null) 3076 { 3077 if (settings.Stickers.Position == StickersListPosition.Custom) 3078 { 3079 @Render(settings.Stickers); 3080 } 3081 } 3082 @if (!String.IsNullOrEmpty(settings.Title)) 3083 { 3084 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 3085 } 3086 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3087 { 3088 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3089 } 3090 @if (!String.IsNullOrEmpty(settings.Summary)) 3091 { 3092 <p class="article__short-summary dw-mod">@settings.Summary</p> 3093 } 3094 </div> 3095 } 3096 </a> 3097 } 3098 3099 @helper RenderArticleListItemList(ArticleListItem settings) { 3100 <a href="@settings.Link"> 3101 <div class="grid u-color-light--bg u-no-padding dw-mod"> 3102 <div class="grid__col-md-3"> 3103 <div class="u-color-light--bg u-no-padding dw-mod"> 3104 @if (settings.Logo != null) 3105 { 3106 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 3107 settings.Logo.ImageDefault.Crop = 5; 3108 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 3109 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 3110 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 3111 @if (settings.Stickers != null) 3112 { 3113 if (settings.Stickers.Position != StickersListPosition.Custom) 3114 { 3115 @Render(settings.Stickers); 3116 } 3117 } 3118 @RenderImage(settings.Logo) 3119 </div> 3120 } else if (settings.Image != null) 3121 { 3122 <div class="flex-img image-hover__wrapper dw-mod"> 3123 @if (settings.Stickers != null) 3124 { 3125 if (settings.Stickers.Position != StickersListPosition.Custom) 3126 { 3127 @Render(settings.Stickers); 3128 } 3129 } 3130 @Render(settings.Image) 3131 </div> 3132 } 3133 </div> 3134 </div> 3135 3136 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 3137 { 3138 <div class="grid__col-md-9"> 3139 @if (!String.IsNullOrEmpty(settings.Title)) 3140 { 3141 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 3142 } 3143 @if (settings.Stickers != null) 3144 { 3145 if (settings.Stickers.Position == StickersListPosition.Custom) 3146 { 3147 @Render(settings.Stickers); 3148 } 3149 } 3150 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3151 { 3152 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3153 } 3154 @if (!String.IsNullOrEmpty(settings.Summary)) 3155 { 3156 <p class="article__short-summary dw-mod">@settings.Summary</p> 3157 } 3158 </div> 3159 } 3160 </div> 3161 </a> 3162 } 3163 3164 @helper RenderArticleListItemSimple(ArticleListItem settings) { 3165 <a href="@settings.Link" class="u-color-inherit"> 3166 <div class="grid u-color-light--bg u-no-padding dw-mod"> 3167 <div class="grid__col-md-12"> 3168 @if (!String.IsNullOrEmpty(settings.Title)) 3169 { 3170 <div class="article-list-item__header u-truncate-text u-no-margin dw-mod">@settings.Title</div> 3171 } 3172 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3173 { 3174 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3175 } 3176 </div> 3177 </div> 3178 </a> 3179 } 3180 @using System.Reflection 3181 @using Dynamicweb.Rapido.Blocks.Components.Articles 3182 3183 3184 @* Component for the articles *@ 3185 3186 @helper RenderArticleAuthorAndDate(ArticleAuthorAndDate settings) 3187 { 3188 <small class="article__subscription"> 3189 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3190 { 3191 <text>@Translate("Written")</text> 3192 } 3193 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3194 { 3195 <text>@Translate("by") @settings.Author</text> 3196 } 3197 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3198 { 3199 <text>@Translate("on") @settings.Date</text> 3200 } 3201 </small> 3202 } 3203 @using System.Reflection 3204 @using Dynamicweb.Rapido.Blocks.Components.Articles 3205 @using Dynamicweb.Rapido.Blocks.Components.General 3206 3207 3208 @* Component for the articles *@ 3209 3210 @helper RenderArticleLink(ArticleLink settings) 3211 { 3212 if (!string.IsNullOrEmpty(settings.Title)) 3213 { 3214 Button link = new Button { 3215 ConfirmText = settings.ConfirmText, 3216 ConfirmTitle = settings.ConfirmTitle, 3217 ButtonType = settings.ButtonType, 3218 Id = settings.Id, 3219 Title = settings.Title, 3220 AltText = settings.AltText, 3221 OnClick = settings.OnClick, 3222 CssClass = settings.CssClass, 3223 Disabled = settings.Disabled, 3224 Icon = settings.Icon, 3225 Name = settings.Name, 3226 Href = settings.Href, 3227 ButtonLayout = settings.ButtonLayout, 3228 ExtraAttributes = settings.ExtraAttributes 3229 }; 3230 <div class="grid__cell"> 3231 @Render(link) 3232 </div> 3233 } 3234 } 3235 @using System.Reflection 3236 @using Dynamicweb.Rapido.Blocks 3237 @using Dynamicweb.Rapido.Blocks.Components.Articles 3238 @using Dynamicweb.Rapido.Blocks.Components.General 3239 3240 3241 @* Component for the articles *@ 3242 3243 @helper RenderArticleCarousel(ArticleCarousel settings) 3244 { 3245 <div class="grid"> 3246 <div class="grid__col-12"> 3247 <div class="carousel" id="carousel_@settings.Id"> 3248 <div class="carousel__container js-carousel-slides dw-mod"> 3249 @RenderBlockList(settings.SubBlocks) 3250 </div> 3251 </div> 3252 </div> 3253 </div> 3254 3255 <script> 3256 document.addEventListener("DOMContentLoaded", function () { 3257 new CarouselModule("#carousel_@settings.Id", { 3258 slideTime: 0, 3259 dots: true 3260 }); 3261 }); 3262 </script> 3263 } 3264 3265 @helper RenderArticleCarouselSlide(ArticleCarouselSlide settings) 3266 { 3267 string imageEngine = "/Admin/Public/GetImage.ashx?"; 3268 3269 string defaultImage = settings.ImageSettings != null ? imageEngine : settings.Image; 3270 if (settings.ImageSettings != null) 3271 { 3272 defaultImage += settings.ImageSettings.Width != 0 ? "Width=" + settings.ImageSettings.Width + "&" : ""; 3273 defaultImage += settings.ImageSettings.Height != 0 ? "Height=" + settings.ImageSettings.Height + "&" : ""; 3274 defaultImage += "Crop=" + settings.ImageSettings.Crop + "&"; 3275 defaultImage += "Compression=" + settings.ImageSettings.Compression + "&"; 3276 defaultImage += "DoNotUpscale=" + settings.ImageSettings.DoNotUpscale.ToString() + "&"; 3277 defaultImage += "FillCanvas=" + settings.ImageSettings.FillCanvas.ToString() + "&"; 3278 } 3279 defaultImage += "&Image=" + settings.Image; 3280 3281 <div class="carousel__slide u-min-h300px u-flex dw-mod" style="background-size:cover; background-image:url('@defaultImage')"> 3282 <a class="article-carousel-item__wrap" href="@settings.Link" title="@settings.Title"> 3283 <h2 class="article-list__item-header u-truncate-text u-color-light dw-mod">@settings.Title</h2> 3284 <div class="article-list__item-info"> 3285 @if (settings.Stickers != null) 3286 { 3287 settings.Stickers.Position = StickersListPosition.Custom; 3288 @Render(settings.Stickers); 3289 } 3290 3291 <small class="u-margin-top--lg u-color-light"> 3292 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3293 { 3294 <text>@Translate("Written")</text> 3295 } 3296 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3297 { 3298 <text>@Translate("by") @settings.Author</text> 3299 } 3300 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3301 { 3302 <text>@Translate("on") @settings.Date</text> 3303 } 3304 </small> 3305 </div> 3306 3307 <h3 class="article__short-summary u-color-light">@settings.Summary</h3> 3308 </a> 3309 @if (settings.UseFilters == true) 3310 { 3311 <div class="background-image image-filter image-filter--darken dw-mod"></div> 3312 } 3313 </div> 3314 } 3315 @using System.Text.RegularExpressions 3316 @using Dynamicweb.Rapido.Blocks.Components 3317 @using Dynamicweb.Rapido.Blocks.Components.General 3318 @using Dynamicweb.Rapido.Blocks.Components.Articles 3319 @using Dynamicweb.Rapido.Blocks 3320 3321 @* Component for the articles *@ 3322 3323 @helper RenderArticleVideo(ArticleVideo settings) 3324 { 3325 if (settings.Url != null) 3326 { 3327 //getting video ID from youtube URL 3328 string videoCode = settings.Url; 3329 Regex regex = new Regex(@".be\/(.[^?]*)"); 3330 Match match = regex.Match(videoCode); 3331 string videoId = ""; 3332 if (match.Success) 3333 { 3334 videoId = match.Groups[1].Value; 3335 } 3336 else 3337 { 3338 regex = new Regex(@"v=([^&]+)"); 3339 match = regex.Match(videoCode); 3340 if (match.Success) 3341 { 3342 videoId = match.Groups[1].Value; 3343 } 3344 } 3345 3346 int autoPlay = settings.AutoPlay == "true" ? 1 : 0; 3347 3348 <div class="video-wrapper"> 3349 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Guid.NewGuid().ToString("N"))" data-auto-play="@autoPlay" data-enable-controls="1"></div> 3350 </div> 3351 } 3352 } 3353 3354 3355 3356 @* Simple helpers *@ 3357 3358 @*Requires the Gallery ItemType that comes with Rapido*@ 3359 @helper RenderArticleItemGallery(IList<ItemViewModel> gallery) { 3360 if (gallery != null && gallery.Count > 0) 3361 { 3362 int count = 1; 3363 3364 foreach (var item in gallery) 3365 { 3366 if (item.GetFile("ImagePath") != null) 3367 { 3368 string image = item.GetFile("ImagePath").PathUrlEncoded; 3369 string imagePrefix = "/Admin/Public/GetImage.ashx?width=1200&amp;height=820&amp;crop=5&amp;Compression=75&amp;DoNotUpscale=1&amp;image="; 3370 int imagesCount = gallery.Count; 3371 3372 if (count == 1) 3373 { 3374 <label class="gallery" for="ParagraphGalleryModalTrigger" onclick="Gallery.openImage(this.querySelector('.js-gallery'))"> 3375 <span class="gallery__main-image"> 3376 <img src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=1&amp;image=@image" class="b-lazy flex-img js-gallery" alt="" data-for="ParagraphGallery" data-image="@imagePrefix@image" /> 3377 </span> 3378 <span class="gallery__image-counter"> 3379 <i class="fas fa-camera fa-2x"></i> <span class="gallery__image-counter__number">@imagesCount</span> 3380 <span class="gallery__image-counter__text">@Translate("See all") <i class="fas fa-angle-right"></i></span> 3381 </span> 3382 </label> 3383 } 3384 else 3385 { 3386 <div class="u-hidden js-gallery" data-for="ParagraphGallery" data-image="@imagePrefix@image"></div> 3387 } 3388 3389 count++; 3390 } 3391 } 3392 3393 @Render(new ArticleGalleryModal()) 3394 } 3395 } 3396 3397 @helper RenderMobileFilters(List<Block> subBlocks) 3398 { 3399 if (subBlocks.Count > 0) 3400 { 3401 <div class="grid__col-12"> 3402 <input type="checkbox" id="CheckFilters" class="js-remember-state u-hidden" data-expand="CheckFilters" /> 3403 <div class="grid u-margin-bottom dw-mod" data-trigger="CheckFilters"> 3404 @RenderBlockList(subBlocks) 3405 </div> 3406 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod js-expand-hide" data-trigger="CheckFilters">@Translate("Select filters")</label> 3407 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod expandable--collapsed" data-trigger="CheckFilters">@Translate("Close filters")</label> 3408 </div> 3409 } 3410 } 3411 3412 3413 @* Include the Blocks for the page *@ 3414 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3415 3416 @using System 3417 @using System.Web 3418 @using System.Collections.Generic 3419 @using Dynamicweb.Rapido.Blocks.Extensibility 3420 @using Dynamicweb.Rapido.Blocks 3421 3422 @functions { 3423 string GoogleTagManagerID = ""; 3424 string GoogleAnalyticsID = ""; 3425 } 3426 3427 @{ 3428 GoogleTagManagerID = Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"); 3429 GoogleAnalyticsID = Model.Area.Item.GetItem("Settings").GetString("GoogleAnalyticsTrackingID"); 3430 3431 BlocksPage topSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 3432 3433 if (!string.IsNullOrWhiteSpace(GoogleAnalyticsID)) 3434 { 3435 Block tagManager = new Block() 3436 { 3437 Id = "GoogleAnalytics", 3438 SortId = 0, 3439 Template = RenderGoogleAnalyticsSnippet() 3440 }; 3441 topSnippetsBlocksPage.Add("Head", tagManager); 3442 } 3443 3444 if (!string.IsNullOrWhiteSpace(GoogleTagManagerID)) 3445 { 3446 Block tagManager = new Block() 3447 { 3448 Id = "TagManager", 3449 SortId = 1, 3450 Template = RenderGoogleTagManager() 3451 }; 3452 topSnippetsBlocksPage.Add("Head", tagManager); 3453 3454 Block tagManagerBodySnippet = new Block() 3455 { 3456 Id = "TagManagerBodySnippet", 3457 SortId = 1, 3458 Template = RenderGoogleTagManagerBodySnippet() 3459 }; 3460 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, tagManagerBodySnippet); 3461 } 3462 3463 Block facebookPixel = new Block() 3464 { 3465 Id = "FacebookPixel", 3466 SortId = 2, 3467 Template = RenderFacebookPixel() 3468 }; 3469 3470 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, facebookPixel); 3471 } 3472 3473 @helper RenderGoogleAnalyticsSnippet() 3474 { 3475 <!-- Global site tag (gtag.js) - Google Analytics --> 3476 <script async src="https://www.googletagmanager.com/gtag/js?id=@GoogleAnalyticsID"></script> 3477 <script> 3478 window.dataLayer = window.dataLayer || []; 3479 function gtag(){dataLayer.push(arguments);} 3480 gtag('js', new Date()); 3481 3482 gtag('config', '@GoogleAnalyticsID'); 3483 </script> 3484 3485 } 3486 3487 @helper RenderGoogleTagManager() 3488 { 3489 <script> 3490 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 3491 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 3492 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 3493 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 3494 })(window,document,'script','dataLayer','@GoogleTagManagerID'); 3495 </script> 3496 } 3497 3498 @helper RenderGoogleTagManagerBodySnippet() 3499 { 3500 <!-- Google Tag Manager (noscript) --> 3501 <noscript> 3502 <iframe src="https://www.googletagmanager.com/ns.html?id=@GoogleTagManagerID" 3503 height="0" width="0" style="display:none;visibility:hidden"></iframe> 3504 </noscript> 3505 <!-- End Google Tag Manager (noscript) --> 3506 } 3507 3508 @helper RenderFacebookPixel() 3509 { 3510 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID"); 3511 3512 if (!string.IsNullOrWhiteSpace(FacebookPixelID)) 3513 { 3514 <!-- Facebook Pixel Code --> 3515 <script> 3516 !function(f,b,e,v,n,t,s) 3517 {if(f.fbq)return;n=f.fbq=function(){n.callMethod? 3518 n.callMethod.apply(n,arguments):n.queue.push(arguments)}; 3519 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; 3520 n.queue=[];t=b.createElement(e);t.async=!0; 3521 t.src=v;s=b.getElementsByTagName(e)[0]; 3522 s.parentNode.insertBefore(t,s)}(window, document,'script', 3523 'https://connect.facebook.net/en_US/fbevents.js'); 3524 fbq('init', '@FacebookPixelID'); 3525 fbq('track', 'PageView'); 3526 </script> 3527 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript> 3528 } 3529 } 3530 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3531 3532 @using System 3533 @using System.Web 3534 @using System.Collections.Generic 3535 @using Dynamicweb.Rapido.Blocks 3536 @using Dynamicweb.Rapido.Blocks.Extensibility 3537 @using Dynamicweb.Security.UserManagement 3538 @using Dynamicweb.Security.UserManagement.ExternalAuthentication 3539 @using Dynamicweb.Rapido.Blocks.Components.General 3540 3541 @{ 3542 BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master"); 3543 3544 Block loginModal = new Block() 3545 { 3546 Id = "LoginModal", 3547 SortId = 10, 3548 Component = new Modal 3549 { 3550 Id = "SignIn", 3551 Heading = new Heading 3552 { 3553 Level = 0, 3554 Title = Translate("Sign in") 3555 }, 3556 Width = ModalWidth.Xs, 3557 BodyTemplate = RenderLoginForm() 3558 } 3559 }; 3560 3561 loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal); 3562 } 3563 3564 @helper RenderLoginForm() 3565 { 3566 int pageId = Model.TopPage.ID; 3567 string userSignedInErrorText = ""; 3568 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 3569 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; 3570 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 3571 bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Model.LogOnFailed; 3572 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 3573 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); 3574 3575 ProviderCollection providers = Provider.GetActiveProviders(); 3576 3577 if (Model.LogOnFailed) 3578 { 3579 switch (Model.LogOnFailedReason) 3580 { 3581 case LogOnFailedReason.PasswordLengthInvalid: 3582 userSignedInErrorText = Translate("Password length is invalid"); 3583 break; 3584 case LogOnFailedReason.IncorrectLogin: 3585 userSignedInErrorText = Translate("Invalid email or password"); 3586 break; 3587 case LogOnFailedReason.ExceededFailedLogOnLimit: 3588 userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked"); 3589 break; 3590 case LogOnFailedReason.LoginLocked: 3591 userSignedInErrorText = Translate("The user account is temporarily locked"); 3592 break; 3593 case LogOnFailedReason.PasswordExpired: 3594 userSignedInErrorText = Translate("The password has expired and needs to be renewed"); 3595 break; 3596 default: 3597 userSignedInErrorText = Translate("An unknown error occured"); 3598 break; 3599 } 3600 } 3601 3602 Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm" }; 3603 3604 form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) }); 3605 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" }); 3606 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" }); 3607 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" }); 3608 form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Email"), CssClass = "u-full-width", Required = true }); 3609 form.Add(new TextField { Id = "LoginPassword", Name = "password", Type = TextFieldType.Password, Label = Translate("Password"), CssClass = "u-full-width", Required = true }); 3610 form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error }); 3611 form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") }); 3612 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" }); 3613 3614 foreach (Provider LoginProvider in providers) 3615 { 3616 var ProviderName = LoginProvider.Name.ToLower(); 3617 form.Add(new Link { 3618 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID, 3619 Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After }, 3620 ButtonLayout = ButtonLayout.LinkClean, 3621 CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName, 3622 AltText = ProviderName 3623 }); 3624 } 3625 3626 if (!hideCreateAccountLink) { 3627 form.Add(new Link { Href = "/default.aspx?ID=" + createAccountPageId, Title = Translate("Create account?"), ButtonLayout = ButtonLayout.None, CssClass = "u-block u-padding-bottom" }); 3628 } 3629 3630 if (!hideForgotPasswordLink) { 3631 form.Add(new Link { Href = forgotPasswordPageLink, Title = Translate("Forgot your password?"), ButtonLayout = ButtonLayout.None, CssClass = "u-block u-padding-bottom" }); 3632 } 3633 3634 @Render(form) 3635 3636 if (showModalOnStart) 3637 { 3638 <script> 3639 document.getElementById("SignInModalTrigger").checked = true; 3640 </script> 3641 } 3642 } 3643 3644 @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 3645 { 3646 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3647 3648 @using System 3649 @using System.Web 3650 @using System.Collections.Generic 3651 @using Dynamicweb.Rapido.Blocks.Extensibility 3652 @using Dynamicweb.Rapido.Blocks 3653 @using Dynamicweb.Rapido.Services 3654 3655 3656 @functions { 3657 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3658 } 3659 3660 @{ 3661 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 3662 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 3663 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed(); 3664 3665 Block mobileHeader = new Block() 3666 { 3667 Id = "MobileTop", 3668 SortId = 10, 3669 Template = RenderMobileTop(), 3670 SkipRenderBlocksList = true 3671 }; 3672 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader); 3673 3674 Block mobileHeaderNavigation = new Block() 3675 { 3676 Id = "MobileHeaderNavigation", 3677 SortId = 10, 3678 Template = RenderMobileHeaderNavigation(), 3679 SkipRenderBlocksList = true, 3680 BlocksList = new List<Block> { 3681 new Block { 3682 Id = "MobileHeaderNavigationTrigger", 3683 SortId = 10, 3684 Template = RenderMobileHeaderNavigationTrigger() 3685 } 3686 } 3687 }; 3688 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation); 3689 3690 Block mobileHeaderLogo = new Block() 3691 { 3692 Id = "MobileHeaderLogo", 3693 SortId = 20, 3694 Template = RenderMobileHeaderLogo(), 3695 SkipRenderBlocksList = true 3696 }; 3697 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo); 3698 3699 Block mobileHeaderActions = new Block() 3700 { 3701 Id = "MobileHeaderActions", 3702 SortId = 30, 3703 Template = RenderMobileTopActions(), 3704 SkipRenderBlocksList = true 3705 }; 3706 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions); 3707 3708 if (!mobileHideSearch) 3709 { 3710 Block mobileHeaderSearch = new Block 3711 { 3712 Id = "MobileHeaderSearch", 3713 SortId = 10, 3714 Template = RenderMobileTopSearch() 3715 }; 3716 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch); 3717 } 3718 3719 Block mobileHeaderMiniCart; 3720 3721 if (!mobileHideCart) 3722 { 3723 mobileHeaderMiniCart = new Block 3724 { 3725 Id = "MobileHeaderMiniCart", 3726 SortId = 20, 3727 Template = RenderMobileTopMiniCart() 3728 }; 3729 3730 Block miniCartCounterScriptTemplate = new Block 3731 { 3732 Id = "MiniCartCounterScriptTemplate", 3733 Template = RenderMobileMiniCartCounterContent() 3734 }; 3735 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 3736 } 3737 else 3738 { 3739 mobileHeaderMiniCart = new Block 3740 { 3741 Id = "MobileHeaderMiniCart", 3742 SortId = 20 3743 }; 3744 } 3745 3746 if (!mobileHideSearch) 3747 { 3748 Block mobileHeaderSearchBar = new Block() 3749 { 3750 Id = "MobileHeaderSearchBar", 3751 SortId = 30, 3752 Template = RenderMobileTopSearchBar() 3753 }; 3754 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar); 3755 } 3756 3757 switch (mobileTopLayout) 3758 { 3759 case "nav-left": 3760 mobileHeaderNavigation.SortId = 10; 3761 mobileHeaderLogo.SortId = 20; 3762 mobileHeaderActions.SortId = 30; 3763 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3764 break; 3765 case "nav-right": 3766 mobileHeaderLogo.SortId = 10; 3767 mobileHeaderActions.SortId = 20; 3768 mobileHeaderNavigation.SortId = 30; 3769 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3770 break; 3771 case "nav-search-left": 3772 mobileHeaderNavigation.SortId = 10; 3773 mobileHeaderLogo.SortId = 20; 3774 mobileHeaderActions.SortId = 30; 3775 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3776 break; 3777 case "search-left": 3778 mobileHeaderActions.SortId = 10; 3779 mobileHeaderLogo.SortId = 20; 3780 mobileHeaderNavigation.SortId = 30; 3781 mobileHeaderMiniCart.SortId = 0; 3782 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3783 break; 3784 } 3785 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3786 { 3787 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block { 3788 Id = "CartInitialization", 3789 Template = RenderMobileCartInitialization() 3790 }); 3791 } 3792 } 3793 3794 3795 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3796 3797 @using System 3798 @using System.Web 3799 @using Dynamicweb.Rapido.Blocks.Extensibility 3800 @using Dynamicweb.Rapido.Blocks 3801 3802 @{ 3803 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3804 } 3805 3806 3807 3808 @helper RenderMobileCartInitialization() 3809 { 3810 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3811 <script> 3812 window.cartId = "@miniCartFeedPageId"; 3813 </script> 3814 } 3815 3816 @helper RenderMobileTop() { 3817 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList(); 3818 3819 <nav class="main-navigation-mobile dw-mod"> 3820 <div class="center-container top-container__center-container dw-mod"> 3821 <div class="grid grid--align-center"> 3822 @RenderBlockList(subBlocks) 3823 </div> 3824 </div> 3825 </nav> 3826 } 3827 3828 @helper RenderMobileHeaderNavigation() { 3829 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList(); 3830 3831 <div class="grid__col-auto-width"> 3832 <ul class="menu dw-mod"> 3833 @RenderBlockList(subBlocks) 3834 </ul> 3835 </div> 3836 } 3837 3838 @helper RenderMobileHeaderNavigationTrigger() { 3839 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3840 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label> 3841 </li> 3842 } 3843 3844 @helper RenderMobileHeaderLogo() { 3845 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList(); 3846 3847 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 3848 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : ""; 3849 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 3850 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName"); 3851 3852 string mobileLogo = "/Files/Images/logo-dynamicweb.png"; 3853 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null) 3854 { 3855 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded; 3856 } 3857 3858 if (Path.GetExtension(mobileLogo).ToLower() != ".svg") 3859 { 3860 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&amp;width=100&amp;crop=5&amp;Compression=75&amp;image=" + mobileLogo; 3861 } 3862 else 3863 { 3864 mobileLogo = HttpUtility.UrlDecode(mobileLogo); 3865 } 3866 3867 <div class="grid__col-auto grid__col--bleed"> 3868 <div class="grid__cell @centeredLogo"> 3869 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod"> 3870 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" /> 3871 </a> 3872 </div> 3873 3874 @RenderBlockList(subBlocks) 3875 </div> 3876 } 3877 3878 @helper RenderMobileTopActions() { 3879 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList(); 3880 3881 <div class="grid__col-auto-width"> 3882 <ul class="menu dw-mod"> 3883 @RenderBlockList(subBlocks) 3884 </ul> 3885 </div> 3886 } 3887 3888 @helper RenderMobileTopSearch() { 3889 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3890 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 3891 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 3892 </label> 3893 </li> 3894 } 3895 3896 @helper RenderMobileTopMiniCart() { 3897 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3898 int cartPageId = GetPageIdByNavigationTag("CartPage"); 3899 double cartProductsCount = Model.Cart.TotalProductsCount; 3900 3901 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper"> 3902 <div class="mini-cart dw-mod"> 3903 <a href="/Default.aspx?ID=@cartPageId&Purge=True" id="miniCartCounterWrap" class="menu__link menu__link--icon menu__link--mobile dw-mod js-mini-cart-button"> 3904 <div class="u-inline u-position-relative"> 3905 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i> 3906 <div class="mini-cart__counter dw-mod"> 3907 <div class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false"> 3908 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount"> 3909 @cartProductsCount 3910 </div> 3911 </div> 3912 </div> 3913 </div> 3914 </a> 3915 </div> 3916 </li> 3917 } 3918 3919 @helper RenderMobileTopSearchBar() 3920 { 3921 string searchFeedId = ""; 3922 string searchSecondFeedId = ""; 3923 int groupsFeedId; 3924 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 3925 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 3926 string resultPageLink; 3927 string searchPlaceholder; 3928 string searchType = "product-search"; 3929 string searchTemplate; 3930 string searchContentTemplate = ""; 3931 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 3932 bool showGroups = true; 3933 3934 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch") 3935 { 3936 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 3937 resultPageLink = contentSearchPageLink; 3938 searchPlaceholder = Translate("Search page"); 3939 groupsFeedId = 0; 3940 searchType = "content-search"; 3941 searchTemplate = "SearchPagesTemplate"; 3942 showGroups = false; 3943 } 3944 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch") 3945 { 3946 searchFeedId = productsPageId + "&feed=true"; 3947 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 3948 resultPageLink = Converter.ToString(productsPageId); 3949 searchPlaceholder = Translate("Search products or pages"); 3950 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 3951 searchType = "combined-search"; 3952 searchTemplate = "SearchProductsTemplateWrap"; 3953 searchContentTemplate = "SearchPagesTemplateWrap"; 3954 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 3955 } 3956 else 3957 { 3958 resultPageLink = Converter.ToString(productsPageId); 3959 searchFeedId = productsPageId + "&feed=true"; 3960 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 3961 searchPlaceholder = Translate("Search products"); 3962 searchTemplate = "SearchProductsTemplate"; 3963 searchType = "product-search"; 3964 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 3965 } 3966 3967 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" /> 3968 3969 <div class="main-navigation-mobile typeahead-mobile dw-mod"> 3970 <div class="center-container top-container__center-container dw-mod"> 3971 <div class="grid"> 3972 <div class="grid__col-auto"> 3973 <div class="typeahead-mobile__search-field dw-mod js-typeahead" data-page-size="@(searchType == "combined-search" ? 4 : 8)" id="MobileProductSearch" data-search-feed-id="@searchFeedId" data-search-second-feed-id="@searchSecondFeedId" data-result-page-id="@resultPageLink" data-search-type="@searchType"> 3974 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue"> 3975 @if (string.IsNullOrEmpty(searchSecondFeedId)) 3976 { 3977 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 3978 } 3979 else 3980 { 3981 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid"> 3982 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></div> 3983 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="MobileContentSearchBarContent" data-template="@searchContentTemplate" data-json-feed="/Default.aspx?ID=@searchSecondFeedId" data-init-onload="false"></div> 3984 </div> 3985 } 3986 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button> 3987 </div> 3988 </div> 3989 <div class="grid__col-auto-width"> 3990 <ul class="menu dw-mod"> 3991 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3992 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 3993 <i class="fas fa-times fa-1_5x"></i> 3994 </label> 3995 </li> 3996 </ul> 3997 </div> 3998 </div> 3999 </div> 4000 </div> 4001 } 4002 4003 @helper RenderMobileMiniCartCounterContent() 4004 { 4005 <script id="MiniCartCounterContent" type="text/x-template"> 4006 {{#.}} 4007 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 4008 {{numberofproducts}} 4009 </div> 4010 {{/.}} 4011 </script> 4012 } 4013 </text> 4014 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4015 4016 @using System 4017 @using System.Web 4018 @using System.Collections.Generic 4019 @using Dynamicweb.Rapido.Blocks.Extensibility 4020 @using Dynamicweb.Rapido.Blocks 4021 4022 @functions { 4023 BlocksPage mobileNavigationBlocksPage = BlocksPage.GetBlockPage("Master"); 4024 } 4025 4026 @{ 4027 bool mobileNavigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn"); 4028 bool mobileHideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 4029 bool mobileHideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile"); 4030 bool mobileHideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders"); 4031 bool mobileHideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards"); 4032 bool mobileHideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites"); 4033 4034 Block mobileNavigation = new Block() 4035 { 4036 Id = "MobileNavigation", 4037 SortId = 10, 4038 Template = MobileNavigation(), 4039 SkipRenderBlocksList = true 4040 }; 4041 mobileNavigationBlocksPage.Add(MasterBlockId.MasterTopSnippets, mobileNavigation); 4042 4043 if (Model.CurrentUser.ID > 0 && !mobileHideMyProfileLink) 4044 { 4045 Block mobileNavigationSignIn = new Block 4046 { 4047 Id = "MobileNavigationSignIn", 4048 SortId = 10, 4049 Template = RenderMobileNavigationSignIn() 4050 }; 4051 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationSignIn); 4052 } 4053 4054 Block mobileNavigationMenu = new Block 4055 { 4056 Id = "MobileNavigationMenu", 4057 SortId = 20, 4058 Template = RenderMobileNavigationMenu() 4059 }; 4060 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationMenu); 4061 4062 Block mobileNavigationActions = new Block 4063 { 4064 Id = "MobileNavigationActions", 4065 SortId = 30, 4066 Template = RenderMobileNavigationActions(), 4067 SkipRenderBlocksList = true 4068 }; 4069 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationActions); 4070 4071 if (!mobileNavigationItemsHideSignIn) 4072 { 4073 if (Model.CurrentUser.ID <= 0) 4074 { 4075 Block mobileNavigationSignInAction = new Block 4076 { 4077 Id = "MobileNavigationSignInAction", 4078 SortId = 10, 4079 Template = RenderMobileNavigationSignInAction() 4080 }; 4081 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignInAction); 4082 4083 if (!mobileHideCreateAccountLink) 4084 { 4085 Block mobileNavigationCreateAccountAction = new Block 4086 { 4087 Id = "MobileNavigationCreateAccountAction", 4088 SortId = 20, 4089 Template = RenderMobileNavigationCreateAccountAction() 4090 }; 4091 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationCreateAccountAction); 4092 } 4093 } 4094 else 4095 { 4096 if (!mobileHideMyOrdersLink) 4097 { 4098 Block mobileNavigationOrdersAction = new Block 4099 { 4100 Id = "MobileNavigationOrdersAction", 4101 SortId = 20, 4102 Template = RenderMobileNavigationOrdersAction() 4103 }; 4104 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationOrdersAction); 4105 } 4106 if (!mobileHideMyFavoritesLink) 4107 { 4108 Block mobileNavigationFavoritesAction = new Block 4109 { 4110 Id = "MobileNavigationFavoritesAction", 4111 SortId = 30, 4112 Template = RenderMobileNavigationFavoritesAction() 4113 }; 4114 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationFavoritesAction); 4115 } 4116 if (!mobileHideMySavedCardsLink) 4117 { 4118 Block mobileNavigationSavedCardsAction = new Block 4119 { 4120 Id = "MobileNavigationFavoritesAction", 4121 SortId = 30, 4122 Template = RenderMobileNavigationSavedCardsAction() 4123 }; 4124 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSavedCardsAction); 4125 } 4126 4127 Block mobileNavigationSignOutAction = new Block 4128 { 4129 Id = "MobileNavigationSignOutAction", 4130 SortId = 40, 4131 Template = RenderMobileNavigationSignOutAction() 4132 }; 4133 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignOutAction); 4134 } 4135 } 4136 4137 if (Model.Languages.Count > 1) 4138 { 4139 Block mobileNavigationLanguagesAction = new Block 4140 { 4141 Id = "MobileNavigationLanguagesAction", 4142 SortId = 50, 4143 Template = RenderMobileNavigationLanguagesAction() 4144 }; 4145 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationLanguagesAction); 4146 } 4147 } 4148 4149 4150 @helper MobileNavigation() 4151 { 4152 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigation").OrderBy(item => item.SortId).ToList(); 4153 string mobileTopDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design") != null ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 4154 string position = mobileTopDesign == "nav-left" || mobileTopDesign == "nav-search-left" ? "left" : "right"; 4155 4156 <!-- Trigger for mobile navigation --> 4157 <input type="checkbox" id="MobileNavTrigger" class="mobile-nav-trigger mobile-nav-trigger--@position" autocomplete="off" /> 4158 4159 <!-- Mobile navigation --> 4160 <nav class="mobile-navigation mobile-navigation--@position dw-mod"> 4161 <div class="mobile-navigation__wrapper" id="mobileNavigationWrapper"> 4162 @RenderBlockList(subBlocks) 4163 </div> 4164 </nav> 4165 4166 <label class="mobile-nav-trigger-off" for="MobileNavTrigger"></label> 4167 } 4168 4169 @helper RenderMobileNavigationSignIn() 4170 { 4171 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4172 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4173 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4174 string myProfilePageLink = linkStart + myProfilePageId; 4175 string userName = Model.CurrentUser.FirstName; 4176 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Model.CurrentUser.LastName)) 4177 { 4178 userName += " " + Model.CurrentUser.LastName; 4179 } 4180 if (string.IsNullOrEmpty(userName)) 4181 { 4182 userName = Model.CurrentUser.Name; 4183 } 4184 if (string.IsNullOrEmpty(userName)) 4185 { 4186 userName = Model.CurrentUser.UserName; 4187 } 4188 if (string.IsNullOrEmpty(userName)) 4189 { 4190 userName = Model.CurrentUser.Email; 4191 } 4192 4193 <ul class="menu menu-mobile"> 4194 <li class="menu-mobile__item"> 4195 <a href="@myProfilePageLink" class="menu-mobile__link dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @userName</a> 4196 </li> 4197 </ul> 4198 } 4199 4200 @helper RenderMobileNavigationMenu() 4201 { 4202 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides"; 4203 string menuTemplate = isSlidesDesign ? "BaseMenuForMobileSlides.xslt" : "BaseMenuForMobileExpandable.xslt"; 4204 string levels = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels") : "3"; 4205 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 4206 int startLevel = 0; 4207 4208 @RenderNavigation(new 4209 { 4210 id = "mobilenavigation", 4211 cssclass = "menu menu-mobile dwnavigation", 4212 startLevel = @startLevel, 4213 ecomStartLevel = @startLevel + 1, 4214 endlevel = @levels, 4215 expandmode = "all", 4216 template = @menuTemplate 4217 }) 4218 4219 if (isSlidesDesign) 4220 { 4221 <script> 4222 function goToLevel(level) { document.getElementById('mobileNavigationWrapper').style.left = -(level * 100) + "%"; } 4223 4224 document.addEventListener('DOMContentLoaded', function () { 4225 goToLevel(document.getElementById('mobileNavigationWrapper').querySelectorAll('input[type=radio]:checked').length); 4226 }); 4227 </script> 4228 } 4229 4230 if (renderPagesInToolBar) 4231 { 4232 @RenderNavigation(new 4233 { 4234 id = "topToolsMobileNavigation", 4235 cssclass = "menu menu-mobile dwnavigation", 4236 template = "ToolsMenuForMobile.xslt" 4237 }) 4238 } 4239 } 4240 4241 @helper RenderMobileNavigationActions() 4242 { 4243 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigationActions").OrderBy(item => item.SortId).ToList(); ; 4244 4245 <ul class="menu menu-mobile"> 4246 @RenderBlockList(subBlocks) 4247 </ul> 4248 } 4249 4250 @helper RenderMobileNavigationSignInAction() 4251 { 4252 <li class="menu-mobile__item"> 4253 <label for="SignInModalTrigger" onclick="document.getElementById('MobileNavTrigger').checked = false;" class="menu-mobile__link dw-mod menu-mobile__link--highlighted"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Sign in")</label> 4254 </li> 4255 } 4256 4257 @helper RenderMobileNavigationCreateAccountAction() 4258 { 4259 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 4260 4261 <li class="menu-mobile__item"> 4262 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Default.aspx?ID=@createAccountPageId"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Create account")</a> 4263 </li> 4264 } 4265 4266 @helper RenderMobileNavigationProfileAction() 4267 { 4268 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4269 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4270 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4271 string myProfilePageLink = linkStart + myProfilePageId; 4272 4273 <li class="menu-mobile__item"> 4274 <a href="@myProfilePageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("My Profile")</a> 4275 </li> 4276 } 4277 4278 @helper RenderMobileNavigationOrdersAction() 4279 { 4280 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4281 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4282 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders"); 4283 string myOrdersPageLink = linkStart + myOrdersPageId; 4284 string ordersIcon = "fas fa-list"; 4285 4286 <li class="menu-mobile__item"> 4287 <a href="@myOrdersPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@ordersIcon menu-mobile__link-icon"></i> @Translate("My Orders")</a> 4288 </li> 4289 } 4290 4291 @helper RenderMobileNavigationFavoritesAction() 4292 { 4293 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4294 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4295 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 4296 string myFavoritesPageLink = linkStart + myFavoritesPageId; 4297 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star"; 4298 4299 4300 <li class="menu-mobile__item"> 4301 <a href="@myFavoritesPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@favoritesIcon menu-mobile__link-icon"></i> @Translate("My Favorites")</a> 4302 </li> 4303 } 4304 4305 @helper RenderMobileNavigationSavedCardsAction() 4306 { 4307 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4308 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4309 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards"); 4310 string mySavedCardsPageLink = linkStart + mySavedCardsPageId; 4311 string savedCardsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards").SelectedValue : "fas fa-credit-card"; 4312 4313 <li class="menu-mobile__item"> 4314 <a href="@mySavedCardsPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@savedCardsIcon menu-mobile__link-icon"></i> @Translate("My Saved Cards")</a> 4315 </li> 4316 } 4317 4318 @helper RenderMobileNavigationSignOutAction() 4319 { 4320 int pageId = Model.TopPage.ID; 4321 string signOutIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon").SelectedValue : "far fa-sign-out-alt"; 4322 4323 <li class="menu-mobile__item"> 4324 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Admin/Public/ExtranetLogoff.aspx?ID=@pageId" onclick="RememberState.SetCookie('useAnotherAddress', false)"><i class="@signOutIcon menu-mobile__link-icon"></i> @Translate("Sign out")</a> 4325 </li> 4326 } 4327 4328 @helper RenderMobileNavigationLanguagesAction() 4329 { 4330 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides"; 4331 4332 string selectedLanguage = ""; 4333 foreach (var lang in Model.Languages) 4334 { 4335 if (lang.IsCurrent) 4336 { 4337 selectedLanguage = lang.Name; 4338 } 4339 } 4340 4341 <li class="menu-mobile__item dw-mod"> 4342 @if (isSlidesDesign) 4343 { 4344 <input id="MobileMenuCheck_Language" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(1);"> 4345 } 4346 else 4347 { 4348 <input id="MobileMenuCheck_Language" type="checkbox" class="expand-trigger"> 4349 } 4350 <div class="menu-mobile__link__wrap"> 4351 <label for="MobileMenuCheck_Language" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue menu-mobile__link-icon"></i> @selectedLanguage</label> 4352 <label for="MobileMenuCheck_Language" class="menu-mobile__trigger"></label> 4353 </div> 4354 <ul class="menu-mobile menu-mobile__submenu expand-menu"> 4355 @if (isSlidesDesign) 4356 { 4357 <li class="menu-mobile__item dw-mod"> 4358 <div class="menu-mobile__link__wrap"> 4359 <input id="MobileMenuCheck_Language_back" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(0);" /> 4360 <label for="MobileMenuCheck_Language_back" class="menu-mobile__trigger menu-mobile__trigger--back"></label> 4361 <label for="MobileMenuCheck_Language_back" class="menu-mobile__link dw-mod ">@Translate("Back")</label> 4362 </div> 4363 </li> 4364 } 4365 @foreach (var lang in Model.Languages) 4366 { 4367 <li class="menu-mobile__item dw-mod"> 4368 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod menu-mobile__link--level-1" href="/Default.aspx?ID=@lang.Page.ID">@lang.Name</a> 4369 </li> 4370 } 4371 </ul> 4372 </li> 4373 }</text> 4374 } 4375 else 4376 { 4377 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4378 4379 @using System 4380 @using System.Web 4381 @using System.Collections.Generic 4382 @using Dynamicweb.Rapido.Blocks.Extensibility 4383 @using Dynamicweb.Rapido.Blocks 4384 4385 @functions { 4386 BlocksPage headerBlocksPage = BlocksPage.GetBlockPage("Master"); 4387 } 4388 4389 @{ 4390 Block masterTools = new Block() 4391 { 4392 Id = "MasterDesktopTools", 4393 SortId = 10, 4394 Template = RenderDesktopTools(), 4395 SkipRenderBlocksList = true, 4396 BlocksList = new List<Block> 4397 { 4398 new Block { 4399 Id = "MasterDesktopToolsText", 4400 SortId = 10, 4401 Template = RenderDesktopToolsText(), 4402 Design = new Design 4403 { 4404 Size = "auto", 4405 HidePadding = true, 4406 RenderType = RenderType.Column 4407 } 4408 }, 4409 new Block { 4410 Id = "MasterDesktopToolsNavigation", 4411 SortId = 20, 4412 Template = RenderDesktopToolsNavigation(), 4413 Design = new Design 4414 { 4415 Size = "auto-width", 4416 HidePadding = true, 4417 RenderType = RenderType.Column 4418 } 4419 } 4420 } 4421 }; 4422 headerBlocksPage.Add("MasterHeader", masterTools); 4423 4424 Block masterDesktopExtra = new Block() 4425 { 4426 Id = "MasterDesktopExtra", 4427 SortId = 10, 4428 Template = RenderDesktopExtra(), 4429 SkipRenderBlocksList = true 4430 }; 4431 headerBlocksPage.Add("MasterHeader", masterDesktopExtra); 4432 4433 Block masterDesktopNavigation = new Block() 4434 { 4435 Id = "MasterDesktopNavigation", 4436 SortId = 20, 4437 Template = RenderDesktopNavigation(), 4438 SkipRenderBlocksList = true 4439 }; 4440 headerBlocksPage.Add("MasterHeader", masterDesktopNavigation); 4441 } 4442 4443 @* Include the Blocks for the page *@ 4444 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4445 4446 @using System 4447 @using System.Web 4448 @using Dynamicweb.Rapido.Blocks.Extensibility 4449 @using Dynamicweb.Rapido.Blocks 4450 4451 @{ 4452 Block masterDesktopLogo = new Block 4453 { 4454 Id = "MasterDesktopLogo", 4455 SortId = 10, 4456 Template = RenderDesktopLogo(), 4457 Design = new Design 4458 { 4459 Size = "auto-width", 4460 HidePadding = true, 4461 RenderType = RenderType.Column, 4462 CssClass = "grid--align-self-center" 4463 } 4464 }; 4465 4466 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo); 4467 } 4468 4469 4470 @helper RenderDesktopLogo() 4471 { 4472 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 4473 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4474 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : ""; 4475 alignClass = topLayout == "splitted-center" ? "u-middle" : alignClass; 4476 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png"; 4477 if (Path.GetExtension(logo).ToLower() != ".svg") 4478 { 4479 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight"); 4480 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40; 4481 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&amp;crop=5&amp;Compression=75&amp;image=" + logo; 4482 } 4483 else 4484 { 4485 logo = HttpUtility.UrlDecode(logo); 4486 } 4487 4488 <div class="logo @alignClass dw-mod"> 4489 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block"> 4490 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" /> 4491 </a> 4492 </div> 4493 } 4494 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4495 4496 @using System 4497 @using System.Web 4498 @using Dynamicweb.Rapido.Blocks.Extensibility 4499 @using Dynamicweb.Rapido.Blocks 4500 4501 @functions { 4502 bool isMegaMenu; 4503 } 4504 4505 @{ 4506 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false; 4507 Block masterDesktopMenu = new Block 4508 { 4509 Id = "MasterDesktopMenu", 4510 SortId = 10, 4511 Template = RenderDesktopMenu(), 4512 Design = new Design 4513 { 4514 Size = "auto", 4515 HidePadding = true, 4516 RenderType = RenderType.Column 4517 } 4518 }; 4519 4520 if (isMegaMenu) 4521 { 4522 masterDesktopMenu.Design.CssClass = "u-reset-position"; 4523 } 4524 4525 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu); 4526 } 4527 4528 @helper RenderDesktopMenu() 4529 { 4530 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4531 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : ""; 4532 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout; 4533 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : ""; 4534 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 4535 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders"); 4536 int startLevel = renderPagesInToolBar ? 1 : 0; 4537 4538 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink"); 4539 4540 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment"> 4541 @if (!isMegaMenu) 4542 { 4543 @RenderNavigation(new 4544 { 4545 id = "topnavigation", 4546 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 4547 startLevel = startLevel, 4548 ecomStartLevel = startLevel + 1, 4549 endlevel = 5, 4550 expandmode = "all", 4551 template = "BaseMenuWithDropdown.xslt" 4552 }); 4553 } 4554 else 4555 { 4556 @RenderNavigation(new 4557 { 4558 id = "topnavigation", 4559 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 4560 startLevel = startLevel, 4561 ecomStartLevel = startLevel + 1, 4562 endlevel = 5, 4563 promotionImage = megamenuPromotionImage, 4564 promotionLink = promotionLink, 4565 expandmode = "all", 4566 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(), 4567 template = "BaseMegaMenu.xslt" 4568 }); 4569 } 4570 </div> 4571 } 4572 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4573 4574 @using System 4575 @using System.Web 4576 @using Dynamicweb.Rapido.Blocks.Extensibility 4577 @using Dynamicweb.Rapido.Blocks 4578 4579 @{ 4580 Block masterDesktopActionsMenu = new Block 4581 { 4582 Id = "MasterDesktopActionsMenu", 4583 SortId = 10, 4584 Template = RenderDesktopActionsMenu(), 4585 Design = new Design 4586 { 4587 CssClass = "u-flex" 4588 }, 4589 SkipRenderBlocksList = true 4590 4591 }; 4592 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu); 4593 4594 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"))) 4595 { 4596 Block masterDesktopActionsHeaderButton = new Block 4597 { 4598 Id = "MasterDesktopActionsHeaderButton", 4599 SortId = 60, 4600 Template = RenderHeaderButton() 4601 }; 4602 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton); 4603 } 4604 } 4605 4606 @helper RenderDesktopActionsMenu() 4607 { 4608 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList(); 4609 4610 <ul class="menu u-flex dw-mod"> 4611 @RenderBlockList(subBlocks) 4612 </ul> 4613 } 4614 4615 @helper RenderHeaderButton() 4616 { 4617 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText"); 4618 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"); 4619 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : ""; 4620 4621 <li class="menu__item menu__item--horizontal menu--clean dw-mod"> 4622 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-top u-margin-left" href="@headerButtonLink">@headerButtonText</a> 4623 </li> 4624 } 4625 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4626 4627 @using System 4628 @using System.Web 4629 @using Dynamicweb.Core; 4630 @using System.Text.RegularExpressions 4631 @using Dynamicweb.Rapido.Blocks.Extensibility 4632 @using Dynamicweb.Rapido.Blocks 4633 4634 @{ 4635 Block masterDesktopActionsMenuLanguageSelector = new Block 4636 { 4637 Id = "MasterDesktopActionsMenuLanguageSelector", 4638 SortId = 40, 4639 Template = RenderLanguageSelector() 4640 }; 4641 4642 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector); 4643 } 4644 4645 @helper RenderLanguageSelector() 4646 { 4647 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4648 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 4649 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4650 string languageViewType = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue) ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue.ToLower() : ""; 4651 4652 if (Model.Languages.Count > 1) 4653 { 4654 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod"> 4655 <div class="@menuLinkClass dw-mod" title="@Translate("Language")"> 4656 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i> 4657 </div> 4658 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell"> 4659 @foreach (var lang in Model.Languages) 4660 { 4661 string widthClass = "menu__item--fixed-width"; 4662 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name; 4663 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty); 4664 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1); 4665 4666 if (languageViewType == "flag-culture") 4667 { 4668 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName; 4669 } 4670 4671 if (languageViewType == "flag") 4672 { 4673 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>"; 4674 widthClass = ""; 4675 } 4676 4677 if (languageViewType == "name") 4678 { 4679 langInfo = lang.Name; 4680 } 4681 4682 if (languageViewType == "culture") 4683 { 4684 langInfo = cultureName; 4685 widthClass = ""; 4686 } 4687 4688 <div class="menu__item dw-mod @widthClass"> 4689 <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a> 4690 </div> 4691 } 4692 </div> 4693 </li> 4694 } 4695 } 4696 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4697 4698 @using System 4699 @using System.Web 4700 @using Dynamicweb.Rapido.Blocks.Extensibility 4701 @using Dynamicweb.Rapido.Blocks 4702 4703 @{ 4704 Block masterDesktopActionsMenuSignIn = new Block 4705 { 4706 Id = "MasterDesktopActionsMenuSignIn", 4707 SortId = 20, 4708 Template = RenderSignIn() 4709 }; 4710 4711 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn); 4712 } 4713 4714 @helper RenderSignIn() 4715 { 4716 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn"); 4717 string userInitials = ""; 4718 int pageId = Model.TopPage.ID; 4719 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 4720 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard"); 4721 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4722 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders"); 4723 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 4724 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards"); 4725 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft"); 4726 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4727 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 4728 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile"); 4729 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders"); 4730 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards"); 4731 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts"); 4732 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites"); 4733 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); 4734 4735 string linkStart = "/Default.aspx?ID="; 4736 if (Model.CurrentUser.ID <= 0) 4737 { 4738 linkStart += signInProfilePageId + "&RedirectPageId="; 4739 } 4740 4741 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; 4742 string myProfilePageLink = linkStart + myProfilePageId; 4743 string myOrdersPageLink = linkStart + myOrdersPageId; 4744 string myFavoritesPageLink = linkStart + myFavoritesPageId; 4745 string mySavedCardsPageLink = linkStart + mySavedCardsPageId; 4746 string myOrderDraftsLink = linkStart + myOrderDraftsPageId; 4747 4748 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user"; 4749 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star"; 4750 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 4751 4752 if (Model.CurrentUser.ID != 0) 4753 { 4754 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName); 4755 } 4756 4757 if (!navigationItemsHideSignIn) 4758 { 4759 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4760 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean"; 4761 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4762 4763 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod"> 4764 <div class="@menuLinkClass dw-mod"> 4765 @if (Model.CurrentUser.ID <= 0) 4766 { 4767 <div style="text-align:center;"> 4768 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" 4769 title="@Translate("Sign in")"></i> 4770 <div style="font-size:11px; line-height:12px; margin-top:2px; white-space:nowrap;"> 4771 @Translate("Sign in for Prices") 4772 </div> 4773 </div> 4774 } 4775 else 4776 { 4777 <div style="text-align:center;"> 4778 <a href="/default.aspx?ID=@myDashboardPageId" 4779 class="u-color-inherit" 4780 title="@Translate("Customer center")"> 4781 <div class="circle-icon-btn">@userInitials.ToUpper()</div> 4782 </a> 4783 <div style="font-size:11px; line-height:12px; margin-top:2px;"> 4784 @Translate("Account") 4785 </div> 4786 </div> 4787 } 4788 </div> 4789 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod"> 4790 <ul class="list list--clean dw-mod"> 4791 @if (Model.CurrentUser.ID <= 0) 4792 { 4793 <li> 4794 <label for="SignInModalTrigger" class="btn btn--primary btn--full u-no-margin sign-in-modal-trigger-button dw-mod" onclick="setTimeout(function () { document.getElementById('LoginUsername').focus() }, 10)">@Translate("Sign in")</label> 4795 </li> 4796 4797 if (!hideCreateAccountLink) 4798 { 4799 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account")); 4800 } 4801 if (!hideForgotPasswordLink) 4802 { 4803 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?")) 4804 } 4805 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 4806 { 4807 @RenderSeparator() 4808 } 4809 } 4810 @if (!hideMyProfileLink) 4811 { 4812 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon) 4813 } 4814 @if (!hideMyOrdersLink) 4815 { 4816 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list") 4817 } 4818 @if (!hideMyFavoritesLink) 4819 { 4820 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon) 4821 } 4822 @if (!hideMySavedCardsLink) 4823 { 4824 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card") 4825 } 4826 @if (!hideMyOrderDraftsLink) 4827 { 4828 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon) 4829 } 4830 @if (Model.CurrentUser.ID > 0) 4831 { 4832 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 4833 { 4834 @RenderSeparator() 4835 } 4836 4837 //Check if impersonation is on 4838 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 4839 { 4840 <li> 4841 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;"> 4842 @Translate("Sign out") 4843 </div> 4844 </li> 4845 } else { 4846 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, Translate("Sign out")) 4847 } 4848 } 4849 </ul> 4850 </div> 4851 </li> 4852 } 4853 } 4854 4855 @helper RenderListItem(string link, string text, string icon = null) { 4856 <li> 4857 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)"> 4858 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text 4859 </a> 4860 </li> 4861 } 4862 4863 @helper RenderSeparator() 4864 { 4865 <li class="list__seperator dw-mod"></li> 4866 } 4867 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4868 4869 @using System 4870 @using System.Web 4871 @using Dynamicweb.Rapido.Blocks.Extensibility 4872 @using Dynamicweb.Rapido.Blocks 4873 4874 @{ 4875 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites"); 4876 4877 Block masterDesktopActionsMenuFavorites = new Block 4878 { 4879 Id = "MasterDesktopActionsMenuFavorites", 4880 SortId = 30, 4881 Template = RenderFavorites() 4882 }; 4883 4884 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0) 4885 { 4886 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites); 4887 } 4888 } 4889 4890 @helper RenderFavorites() 4891 { 4892 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 4893 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId; 4894 4895 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4896 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 4897 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4898 4899 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 4900 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")"> 4901 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i> 4902 </a> 4903 </li> 4904 } 4905 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4906 4907 @using System 4908 @using System.Web 4909 @using Dynamicweb.Rapido.Blocks.Extensibility 4910 @using Dynamicweb.Rapido.Blocks 4911 @using Dynamicweb.Rapido.Services 4912 4913 @{ 4914 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 4915 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 4916 4917 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart) 4918 { 4919 Block masterDesktopActionsMenuMiniCart = new Block 4920 { 4921 Id = "MasterDesktopActionsMenuMiniCart", 4922 SortId = 60, 4923 Template = RenderMiniCart(miniCartLayout == "dropdown"), 4924 SkipRenderBlocksList = true, 4925 BlocksList = new List<Block>() 4926 }; 4927 4928 Block miniCartCounterScriptTemplate = new Block 4929 { 4930 Id = "MiniCartCounterScriptTemplate", 4931 Template = RenderMiniCartCounterContent() 4932 }; 4933 4934 //dropdown layout is default 4935 RazorEngine.Templating.TemplateWriter layoutTemplate; 4936 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate; 4937 4938 switch (miniCartLayout) 4939 { 4940 case "dropdown": 4941 layoutTemplate = RenderMiniCartDropdownLayout(); 4942 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 4943 break; 4944 case "panel": 4945 layoutTemplate = RenderMiniCartPanelLayout(); 4946 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 4947 break; 4948 case "modal": 4949 layoutTemplate = RenderMiniCartModalLayout(); 4950 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 4951 break; 4952 case "none": 4953 default: 4954 layoutTemplate = RenderNoLayoutMiniCart(); 4955 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 4956 break; 4957 } 4958 4959 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 4960 { 4961 Id = "MiniCartTrigger", 4962 Template = miniCartTriggerTemplate 4963 }); 4964 4965 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 4966 { 4967 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 4968 { 4969 Id = "MiniCartLayout", 4970 Template = layoutTemplate 4971 }); 4972 } 4973 4974 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart); 4975 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 4976 } 4977 4978 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 4979 { 4980 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block { 4981 Id = "CartInitialization", 4982 Template = RenderNoLayoutMiniCart() 4983 }); 4984 } 4985 } 4986 4987 @helper RenderMiniCart(bool hasMouseEnterEvent) 4988 { 4989 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList(); 4990 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4991 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean"; 4992 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 4993 string mouseEvent = ""; 4994 string id = "MiniCart"; 4995 if (hasMouseEnterEvent) 4996 { 4997 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\""; 4998 id = "miniCartTrigger"; 4999 } 5000 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent> 5001 @RenderBlockList(subBlocks) 5002 </li> 5003 } 5004 5005 @helper RenderNoLayoutMiniCart() 5006 { 5007 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5008 <script> 5009 window.cartId = "@miniCartFeedPageId"; 5010 </script> 5011 } 5012 5013 @helper RenderMiniCartTriggerLabel() 5014 { 5015 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5016 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5017 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5018 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5019 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5020 5021 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")"> 5022 <div class="u-inline u-position-relative"> 5023 <i class="@cartIcon fa-1_5x"></i> 5024 @RenderMiniCartCounter() 5025 </div> 5026 </div> 5027 } 5028 5029 @helper RenderMiniCartTriggerLink() 5030 { 5031 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5032 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5033 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5034 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5035 5036 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")"> 5037 <span class="u-inline u-position-relative"> 5038 <i class="@cartIcon fa-1_5x"></i> 5039 @RenderMiniCartCounter() 5040 </span> 5041 </a> 5042 } 5043 5044 @helper RenderMiniCartCounter() 5045 { 5046 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5047 string cartProductsCount = Model.Cart.TotalProductsCount.ToString(); 5048 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5049 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5050 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : ""; 5051 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : ""; 5052 5053 if (showPrice && counterPosition == "right") 5054 { 5055 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")"; 5056 } 5057 5058 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod"> 5059 <span class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false"> 5060 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()"> 5061 @cartProductsCount @cartProductsTotalPrice 5062 </span> 5063 </span> 5064 </span> 5065 } 5066 5067 @helper RenderMiniCartCounterContent() 5068 { 5069 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5070 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5071 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice; 5072 5073 <script id="MiniCartCounterContent" type="text/x-template"> 5074 {{#.}} 5075 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 5076 @if (showPriceInMiniCartCounter) 5077 { 5078 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text> 5079 } 5080 else 5081 { 5082 <text>{{numberofproducts}}</text> 5083 } 5084 </span> 5085 {{/.}} 5086 </script> 5087 } 5088 5089 @helper RenderMiniCartDropdownLayout() 5090 { 5091 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5092 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5093 5094 <div class="mini-cart mini-cart-dropdown js-mini-cart grid__cell dw-mod" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="dropdown" data-cart-page-link="@cartPageLink"> 5095 <div class="mini-cart-dropdown__inner dw-mod"> 5096 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3> 5097 <div class="mini-cart-dropdown__body u-flex dw-mod"> 5098 <div class="js-handlebars-root u-flex grid--direction-column u-full-width dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5099 </div> 5100 </div> 5101 </div> 5102 } 5103 5104 @helper RenderMiniCartPanelLayout() 5105 { 5106 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5107 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5108 5109 <div class="mini-cart grid__cell dw-mod"> 5110 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" /> 5111 <div class="panel panel--right panel--with-close-btn dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 5112 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label> 5113 <div class="panel__content u-full-width dw-mod"> 5114 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3> 5115 <div class="panel__content-body panel__content-body--cart dw-mod"> 5116 <div class="js-handlebars-root u-flex grid--direction-column u-full-height dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5117 </div> 5118 </div> 5119 </div> 5120 </div> 5121 } 5122 5123 @helper RenderMiniCartModalLayout() 5124 { 5125 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5126 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5127 5128 <div class="mini-cart grid__cell dw-mod"> 5129 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" /> 5130 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 5131 <label for="miniCartTrigger" class="modal-overlay"></label> 5132 <div class="modal modal--md modal--top-right dw-mod"> 5133 <div class="modal__body u-flex grid--direction-column dw-mod"> 5134 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3> 5135 <div class="js-handlebars-root u-flex grid--direction-column dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5136 </div> 5137 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label> 5138 </div> 5139 </div> 5140 </div> 5141 } 5142 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5143 5144 @using System 5145 @using System.Web 5146 @using Dynamicweb.Rapido.Blocks.Extensibility 5147 @using Dynamicweb.Rapido.Blocks 5148 5149 @{ 5150 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon"); 5151 5152 Block masterDesktopActionsMenuOrderDraft = new Block 5153 { 5154 Id = "MasterDesktopActionsMenuOrderDraft", 5155 SortId = 40, 5156 Template = RenderOrderDraft() 5157 }; 5158 5159 if (showOrderDraftLink && Model.CurrentUser.ID > 0) 5160 { 5161 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft); 5162 } 5163 } 5164 5165 @helper RenderOrderDraft() 5166 { 5167 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft"); 5168 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId; 5169 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 5170 5171 5172 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5173 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5174 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5175 5176 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5177 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")"> 5178 <span class="u-inline u-position-relative"> 5179 <i class="@draftIcon fa-1_5x"></i> 5180 </span> 5181 </a> 5182 </li> 5183 } 5184 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5185 5186 @using System 5187 @using System.Web 5188 @using Dynamicweb.Rapido.Blocks.Extensibility 5189 @using Dynamicweb.Rapido.Blocks 5190 5191 @{ 5192 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"); 5193 5194 Block masterDesktopActionsMenuDownloadCart = new Block 5195 { 5196 Id = "MasterDesktopActionsMenuDownloadCart", 5197 SortId = 50, 5198 Template = RenderDownloadCart() 5199 }; 5200 5201 if (showDownloadCartLink && Model.CurrentUser.ID > 0) 5202 { 5203 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart); 5204 } 5205 } 5206 5207 @helper RenderDownloadCart() 5208 { 5209 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart"); 5210 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId; 5211 5212 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5213 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5214 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5215 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5216 5217 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5218 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")"> 5219 <span class="u-inline u-position-relative"> 5220 <i class="fas fa-cart-arrow-down fa-1_5x"></i> 5221 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span> 5222 </span> 5223 </a> 5224 </li> 5225 } 5226 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5227 5228 @using System 5229 @using System.Web 5230 @using Dynamicweb.Rapido.Blocks.Extensibility 5231 @using Dynamicweb.Rapido.Blocks 5232 5233 @functions { 5234 public class SearchConfiguration 5235 { 5236 public string searchFeedId { get; set; } 5237 public string searchSecondFeedId { get; set; } 5238 public int groupsFeedId { get; set; } 5239 public string resultPageLink { get; set; } 5240 public string searchPlaceholder { get; set; } 5241 public string searchType { get; set; } 5242 public string searchTemplate { get; set; } 5243 public string searchContentTemplate { get; set; } 5244 public string searchValue { get; set; } 5245 public bool showGroups { get; set; } 5246 5247 public SearchConfiguration() 5248 { 5249 searchFeedId = ""; 5250 searchSecondFeedId = ""; 5251 searchType = "product-search"; 5252 searchContentTemplate = ""; 5253 showGroups = true; 5254 } 5255 } 5256 } 5257 @{ 5258 Block masterSearchBar = new Block 5259 { 5260 Id = "MasterSearchBar", 5261 SortId = 40, 5262 Template = RenderSearch("bar"), 5263 Design = new Design 5264 { 5265 Size = "auto", 5266 HidePadding = true, 5267 RenderType = RenderType.Column 5268 } 5269 }; 5270 5271 Block masterSearchAction = new Block 5272 { 5273 Id = "MasterDesktopActionsMenuSearch", 5274 SortId = 10, 5275 Template = RenderSearch() 5276 }; 5277 5278 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar); 5279 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction); 5280 } 5281 5282 @helper RenderSearch(string type = "mini-search") 5283 { 5284 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage")); 5285 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 5286 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch"; 5287 5288 SearchConfiguration searchConfiguration = null; 5289 5290 switch (searchType) { 5291 case "contentSearch": 5292 searchConfiguration = new SearchConfiguration() { 5293 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5294 resultPageLink = contentSearchPageLink, 5295 searchPlaceholder = Translate("Search page"), 5296 groupsFeedId = 0, 5297 searchType = "content-search", 5298 searchTemplate = "SearchPagesTemplate", 5299 showGroups = false 5300 }; 5301 break; 5302 case "combinedSearch": 5303 searchConfiguration = new SearchConfiguration() { 5304 searchFeedId = productsPageId + "&feed=true", 5305 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5306 resultPageLink = Converter.ToString(productsPageId), 5307 searchPlaceholder = Translate("Search products or pages"), 5308 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5309 searchType = "combined-search", 5310 searchTemplate = "SearchProductsTemplateWrap", 5311 searchContentTemplate = "SearchPagesTemplateWrap", 5312 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5313 }; 5314 break; 5315 default: //productSearch 5316 searchConfiguration = new SearchConfiguration() { 5317 resultPageLink = Converter.ToString(productsPageId), 5318 searchFeedId = productsPageId + "&feed=true", 5319 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5320 searchPlaceholder = Translate("Search products"), 5321 searchTemplate = "SearchProductsTemplate", 5322 searchType = "product-search", 5323 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5324 }; 5325 break; 5326 } 5327 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 5328 5329 if (type == "mini-search") { 5330 @RenderMiniSearch(searchConfiguration) 5331 } else { 5332 @RenderSearchBar(searchConfiguration) 5333 } 5334 } 5335 5336 @helper RenderSearchBar(SearchConfiguration options) 5337 { 5338 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar" 5339 data-page-size="7" 5340 data-search-feed-id="@options.searchFeedId" 5341 data-search-second-feed-id="@options.searchSecondFeedId" 5342 data-result-page-id="@options.resultPageLink" 5343 data-groups-page-id="@options.groupsFeedId" 5344 data-search-type="@options.searchType"> 5345 @if (options.showGroups) 5346 { 5347 <button type="button" class="btn btn--condensed u-color-light-gray--bg typeahead-group-btn dw-mod js-typeahead-groups-btn" data-group-id="all">@Translate("All")</button> 5348 <ul class="dropdown dropdown--absolute-position u-min-w220px js-handlebars-root js-typeahead-groups-content dw-mod" id="ProductSearchBarGroupsContent" data-template="SearchGroupsTemplate" data-json-feed="/Default.aspx?ID=@options.groupsFeedId&feedType=productGroups" data-init-onload="false" data-preloader="minimal"></ul> 5349 } 5350 <div class="typeahead-search-field"> 5351 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 5352 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5353 { 5354 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 5355 } 5356 else 5357 { 5358 <div class="dropdown dropdown--absolute-position dropdown--combined grid"> 5359 <div class="js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-init-onload="false"></div> 5360 <div class="js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-init-onload="false"></div> 5361 </div> 5362 } 5363 </div> 5364 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn" title="@Translate("Search")"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button> 5365 </div> 5366 } 5367 5368 @helper RenderMiniSearch(SearchConfiguration options) 5369 { 5370 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5371 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5372 5373 <li class="menu__item menu__item--horizontal menu__item--top-level menu__item--icon u-hidden-xxs is-dropdown is-dropdown--no-icon dw-mod" id="miniSearchIcon"> 5374 <div class="@menuLinkClass dw-mod" title="@Translate("Search")"> 5375 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 5376 </div> 5377 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod"> 5378 <div class="typeahead js-typeahead" id="ProductSearchBar" 5379 data-page-size="7" 5380 data-search-feed-id="@options.searchFeedId" 5381 data-search-second-feed-id="@options.searchSecondFeedId" 5382 data-result-page-id="@options.resultPageLink" 5383 data-search-type="@options.searchType"> 5384 <div class="typeahead-search-field"> 5385 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 5386 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5387 { 5388 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 5389 } 5390 else 5391 { 5392 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned"> 5393 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></div> 5394 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-json-feed="/Default.aspx?ID=@options.searchSecondFeedId" data-init-onload="false"></div> 5395 </div> 5396 } 5397 </div> 5398 </div> 5399 </div> 5400 </li> 5401 } 5402 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5403 5404 @using System 5405 @using System.Web 5406 @using Dynamicweb.Rapido.Blocks.Extensibility 5407 @using Dynamicweb.Rapido.Blocks 5408 5409 @{ 5410 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5411 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 5412 5413 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master"); 5414 5415 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo"); 5416 headerConfigurationPage.RemoveBlock(configDesktopLogo); 5417 5418 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu"); 5419 headerConfigurationPage.RemoveBlock(configDesktopMenu); 5420 5421 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar"); 5422 headerConfigurationPage.RemoveBlock(configSearchBar); 5423 5424 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch"); 5425 headerConfigurationPage.RemoveBlock(configSearchAction); 5426 5427 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu"); 5428 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu); 5429 5430 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra"); 5431 5432 switch (headerConfigurationTopLayout) 5433 { 5434 case "condensed": //2 5435 configDesktopLogo.Design.Size = "auto-width"; 5436 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5437 5438 configDesktopMenu.SortId = 20; 5439 configDesktopMenu.Design.Size = "auto"; 5440 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5441 5442 configDesktopActionsMenu.SortId = 30; 5443 configDesktopActionsMenu.Design.Size = "auto-width"; 5444 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5445 5446 if (!headerConfigurationHideSearch) 5447 { 5448 configSearchBar.SortId = 40; 5449 configSearchBar.Design.Size = "12"; 5450 configDesktopExtra.SortId = 50; 5451 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5452 } 5453 break; 5454 case "splitted": //3 5455 configDesktopLogo.Design.Size = "auto"; 5456 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5457 5458 if (!headerConfigurationHideSearch) 5459 { 5460 configSearchBar.SortId = 20; 5461 configSearchBar.Design.Size = "auto"; 5462 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5463 } 5464 5465 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5466 5467 configDesktopActionsMenu.SortId = 20; 5468 configDesktopActionsMenu.Design.Size = "auto-width"; 5469 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5470 break; 5471 case "splitted-center": //4 5472 configDesktopLogo.Design.Size = "auto"; 5473 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5474 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5475 5476 configDesktopActionsMenu.SortId = 30; 5477 configDesktopActionsMenu.Design.Size = "auto-width"; 5478 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 5479 5480 if (!headerConfigurationHideSearch) 5481 { 5482 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5483 } 5484 break; 5485 case "minimal": //5 5486 configDesktopLogo.Design.Size = "auto-width"; 5487 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5488 5489 configDesktopMenu.Design.Size = "auto"; 5490 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5491 5492 configDesktopActionsMenu.SortId = 20; 5493 configDesktopActionsMenu.Design.Size = "auto-width"; 5494 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5495 5496 if (!headerConfigurationHideSearch) 5497 { 5498 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5499 } 5500 break; 5501 case "minimal-center": //6 5502 configDesktopLogo.Design.Size = "auto-width"; 5503 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5504 5505 configDesktopMenu.Design.Size = "auto"; 5506 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5507 5508 configDesktopActionsMenu.SortId = 20; 5509 configDesktopActionsMenu.Design.Size = "auto-width"; 5510 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5511 5512 if (!headerConfigurationHideSearch) 5513 { 5514 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5515 } 5516 break; 5517 case "minimal-right": //7 5518 configDesktopLogo.Design.Size = "auto-width"; 5519 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5520 5521 configDesktopMenu.Design.Size = "auto"; 5522 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5523 5524 configDesktopActionsMenu.SortId = 20; 5525 configDesktopActionsMenu.Design.Size = "auto-width"; 5526 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5527 5528 if (!headerConfigurationHideSearch) 5529 { 5530 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5531 } 5532 break; 5533 case "two-lines": //8 5534 configDesktopLogo.Design.Size = "auto"; 5535 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5536 5537 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5538 5539 configDesktopActionsMenu.SortId = 20; 5540 configDesktopActionsMenu.Design.Size = "auto-width"; 5541 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5542 5543 if (!headerConfigurationHideSearch) 5544 { 5545 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5546 } 5547 break; 5548 case "two-lines-centered": //9 5549 configDesktopLogo.Design.Size = "auto"; 5550 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5551 5552 configDesktopMenu.Design.Size = "auto-width"; 5553 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5554 5555 configDesktopActionsMenu.SortId = 20; 5556 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5557 5558 if (!headerConfigurationHideSearch) 5559 { 5560 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5561 } 5562 break; 5563 case "normal": //1 5564 default: 5565 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5566 5567 if (!headerConfigurationHideSearch) 5568 { 5569 configSearchBar.SortId = 20; 5570 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5571 } 5572 5573 configDesktopActionsMenu.SortId = 30; 5574 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 5575 5576 configDesktopActionsMenu.Design.Size = "auto-width"; 5577 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5578 break; 5579 } 5580 } 5581 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5582 5583 @using System 5584 @using System.Web 5585 @using Dynamicweb.Rapido.Blocks.Extensibility 5586 @using Dynamicweb.Rapido.Blocks 5587 5588 @{ 5589 5590 } 5591 5592 5593 @helper RenderDesktopTools() 5594 { 5595 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList(); 5596 5597 <div class="tools-navigation dw-mod"> 5598 <div class="center-container grid top-container__center-container dw-mod"> 5599 @RenderBlockList(subBlocks) 5600 </div> 5601 </div> 5602 } 5603 5604 @helper RenderDesktopToolsText() 5605 { 5606 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText"); 5607 if (!string.IsNullOrEmpty(toolsText)) 5608 { 5609 <div class="u-margin-top u-margin-bottom">@toolsText</div> 5610 } 5611 } 5612 5613 @helper RenderDesktopToolsNavigation() 5614 { 5615 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 5616 5617 if (renderPagesInToolBar) 5618 { 5619 @RenderNavigation(new 5620 { 5621 id = "topToolsNavigation", 5622 cssclass = "menu menu-tools dw-mod dwnavigation", 5623 template = "TopMenu.xslt" 5624 }) 5625 } 5626 } 5627 5628 @helper RenderDesktopNavigation() 5629 { 5630 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList(); 5631 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5632 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : ""; 5633 <nav class="main-navigation dw-mod"> 5634 <div class="center-container top-container__center-container grid @alignClass dw-mod"> 5635 @RenderBlockList(subBlocks) 5636 </div> 5637 </nav> 5638 } 5639 5640 @helper RenderDesktopExtra() 5641 { 5642 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList(); 5643 5644 if (subBlocks.Count > 0) 5645 { 5646 <div class="header header-top dw-mod"> 5647 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod"> 5648 @RenderBlockList(subBlocks) 5649 </div> 5650 </div> 5651 } 5652 }</text> 5653 } 5654 5655 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5656 5657 @using System 5658 @using System.Web 5659 @using Dynamicweb.Rapido.Blocks.Extensibility 5660 @using Dynamicweb.Rapido.Blocks 5661 @using Dynamicweb.Rapido.Blocks.Components.General 5662 @using Dynamicweb.Frontend 5663 5664 @functions { 5665 int impersonationPageId; 5666 string impersonationLayout; 5667 int impersonationFeed; 5668 Block impersonationBar; 5669 5670 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName) 5671 { 5672 string username = ""; 5673 5674 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName)) 5675 { 5676 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName; 5677 } 5678 else if (!string.IsNullOrEmpty(name)) 5679 { 5680 username = name; 5681 } 5682 else if (!string.IsNullOrEmpty(email)) 5683 { 5684 username = email; 5685 } 5686 else 5687 { 5688 username = userName; 5689 } 5690 return username; 5691 } 5692 5693 string getUserName(UserViewModel user) 5694 { 5695 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 5696 } 5697 5698 string getUserName(Dynamicweb.Security.UserManagement.User user) 5699 { 5700 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 5701 } 5702 } 5703 5704 @{ 5705 impersonationPageId = GetPageIdByNavigationTag("Impersonation"); 5706 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar"; 5707 impersonationFeed = GetPageIdByNavigationTag("UsersFeed"); 5708 5709 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0) 5710 { 5711 impersonationBar = new Block 5712 { 5713 Id = "ImpersonationBar", 5714 SortId = 50, 5715 Template = RenderImpersonation(), 5716 SkipRenderBlocksList = true, 5717 Design = new Design 5718 { 5719 Size = "auto-width", 5720 HidePadding = true, 5721 RenderType = RenderType.Column 5722 } 5723 }; 5724 5725 if (impersonationLayout == "top-bar") { 5726 impersonationBar.SortId = 9; 5727 } 5728 5729 Block impersonationContent = new Block 5730 { 5731 Id = "ImpersonationContent", 5732 SortId = 20 5733 }; 5734 5735 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 5736 { 5737 //Render stop impersonation view 5738 impersonationContent.Template = RenderStopImpersonationView(); 5739 5740 5741 Modal stopImpersonation = new Modal 5742 { 5743 Id = "StopImpersonation", 5744 Heading = new Heading { 5745 Level = 2, 5746 Title = Translate("Sign out"), 5747 Icon = new Icon { 5748 Name = "fa-sign-out", 5749 Prefix = "fas", 5750 LabelPosition = IconLabelPosition.After 5751 } 5752 }, 5753 Width = ModalWidth.Sm, 5754 BodyTemplate = RenderStopImpersonationForm() 5755 }; 5756 5757 Block stopImpersonationBlock = new Block 5758 { 5759 Id = "StopImpersonationBlock", 5760 SortId = 10, 5761 Component = stopImpersonation 5762 }; 5763 impersonationBar.BlocksList.Add(stopImpersonationBlock); 5764 } 5765 else 5766 { 5767 //Render main view 5768 switch (impersonationLayout) 5769 { 5770 case "right-lower-box": 5771 impersonationContent.BlocksList.Add( 5772 new Block { 5773 Id = "RightLowerBoxHeader", 5774 SortId = 10, 5775 Component = new Heading { 5776 Level = 5, 5777 Title = Translate("View the list of users you can sign in as"), 5778 CssClass = "impersonation-text" 5779 } 5780 } 5781 ); 5782 impersonationContent.BlocksList.Add( 5783 new Block { 5784 Id = "RightLowerBoxContent", 5785 SortId = 20, 5786 Template = RenderImpersonationControls() 5787 } 5788 ); 5789 break; 5790 case "right-lower-bar": 5791 impersonationContent.BlocksList.Add( 5792 new Block { 5793 Id = "RightLowerBarContent", 5794 SortId = 10, 5795 Template = RenderImpersonationControls() 5796 } 5797 ); 5798 break; 5799 case "bar": 5800 default: 5801 impersonationContent.BlocksList.Add( 5802 new Block { 5803 Id = "ViewListLink", 5804 SortId = 20, 5805 Template = RenderViewListLink() 5806 } 5807 ); 5808 impersonationContent.BlocksList.Add( 5809 new Block { 5810 Id = "BarTypeaheadSearch", 5811 SortId = 30, 5812 Template = RenderTypeaheadSearch() 5813 } 5814 ); 5815 break; 5816 } 5817 } 5818 impersonationBar.BlocksList.Add(impersonationContent); 5819 5820 impersonationBar.BlocksList.Add( 5821 new Block 5822 { 5823 Id = "ImpersonationSearchTemplates", 5824 SortId = 30, 5825 Template = RenderSearchResultTemplate() 5826 } 5827 ); 5828 if (impersonationLayout != "bar" && impersonationLayout != "top-bar") 5829 { 5830 impersonationBar.BlocksList.Add( 5831 new Block 5832 { 5833 Id = "ImpersonationSearchScripts", 5834 SortId = 40, 5835 Template = RenderSearchScripts() 5836 } 5837 ); 5838 } 5839 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar); 5840 } 5841 } 5842 5843 @helper RenderImpersonation() 5844 { 5845 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList(); 5846 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" /> 5847 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation"> 5848 @if (impersonationLayout == "right-lower-box") 5849 { 5850 @RenderRightLowerBoxHeader() 5851 } 5852 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod"> 5853 @*Impersonation*@ 5854 @RenderBlockList(subBlocks) 5855 </div> 5856 </div> 5857 } 5858 5859 @helper RenderRightLowerBoxHeader() 5860 { 5861 <div class="impersonation__header dw-mod"> 5862 <div class="impersonation__title">@Translate("Impersonation")</div> 5863 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();"> 5864 @Render(new Icon 5865 { 5866 Prefix = "fas", 5867 Name = "fa-window-minimize" 5868 }) 5869 </label> 5870 </div> 5871 } 5872 5873 @helper RenderStopImpersonationView() 5874 { 5875 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 5876 string userName = getUserName(Pageview.User); 5877 string impersonationText = "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + secondaryUserName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + userName + "</b> "; 5878 impersonationText = Dynamicweb.Security.UserManagement.User.ImpersonationMode == Dynamicweb.Security.UserManagement.UserImpersonation.Full ? "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + userName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + secondaryUserName + "</b> " : impersonationText; 5879 5880 if (impersonationLayout == "right-lower-box") 5881 { 5882 <div class="u-margin-bottom--lg u-ta-center"> 5883 @impersonationText 5884 </div> 5885 <div class="u-margin-bottom--lg u-ta-center"> 5886 @RenderSwitchAccountButton() 5887 </div> 5888 @RenderStopImpersonationButton() 5889 } 5890 else 5891 { 5892 <div class="grid grid--align-center impersonation__stop-wrap"> 5893 <div class="impersonation-bar-item dw-mod"> 5894 @impersonationText 5895 </div> 5896 <div class="impersonation-bar-item dw-mod"> 5897 @RenderSwitchAccountButton() 5898 </div> 5899 <div class="impersonation-bar-item dw-mod"> 5900 @RenderStopImpersonationButton() 5901 </div> 5902 </div> 5903 } 5904 } 5905 5906 @helper RenderSwitchAccountButton() { 5907 @Render(new Button 5908 { 5909 Href = "/Default.aspx?ID=" + impersonationPageId, 5910 ButtonLayout = ButtonLayout.LinkClean, 5911 Title = Translate("Switch account"), 5912 Icon = new Icon { 5913 Name = "fa-users", 5914 Prefix = "fal", 5915 LabelPosition = IconLabelPosition.After 5916 }, 5917 CssClass = "u-no-margin u-color-inherit" 5918 }) 5919 } 5920 5921 @helper RenderStopImpersonationForm() 5922 { 5923 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 5924 string userName = getUserName(Pageview.User); 5925 int pageId = Model.TopPage.ID; 5926 5927 <form method="post" class="u-no-margin"> 5928 @Render(new Button 5929 { 5930 ButtonType = ButtonType.Submit, 5931 ButtonLayout = ButtonLayout.Secondary, 5932 Title = Translate("Sign out as") + " " + userName, 5933 Href = "/Default.aspx?ID=" + impersonationPageId, 5934 CssClass = "btn--full", 5935 Name = "DwExtranetRemoveSecondaryUser" 5936 }) 5937 5938 @Render(new Button 5939 { 5940 ButtonType = ButtonType.Submit, 5941 ButtonLayout = ButtonLayout.Secondary, 5942 Title = Translate("Sign out as") + " " + secondaryUserName, 5943 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, 5944 CssClass = "btn--full", 5945 Name = "DwExtranetRemoveSecondaryUser" 5946 }) 5947 </form> 5948 } 5949 5950 @helper RenderStopImpersonationButton() { 5951 @Render(new Button 5952 { 5953 ButtonType = ButtonType.Button, 5954 ButtonLayout = ButtonLayout.LinkClean, 5955 Title = Translate("Sign out"), 5956 Icon = new Icon { 5957 Name = "fa-sign-out", 5958 Prefix = "fal", 5959 LabelPosition = IconLabelPosition.After 5960 }, 5961 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true", 5962 CssClass = "u-no-margin" 5963 }) 5964 } 5965 5966 @helper RenderImpersonationControls() 5967 { 5968 <div class="impersonation__controls"> 5969 @RenderViewListLink() 5970 @RenderSearchBox() 5971 </div> 5972 @RenderResultsList() 5973 } 5974 5975 @helper RenderViewListLink() 5976 { 5977 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as"); 5978 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link"; 5979 5980 @Render(new Link { 5981 ButtonLayout = ButtonLayout.None, 5982 Title = title, 5983 Href = "/Default.aspx?ID=" + impersonationPageId, 5984 CssClass = buttonClasses 5985 }) 5986 } 5987 5988 @helper RenderSearchBox() 5989 { 5990 <div class="impersonation__search-wrap"> 5991 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField"> 5992 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)"> 5993 <i class="fal fa-search"></i> 5994 </div> 5995 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();"> 5996 <i class="fal fa-times"></i> 5997 </div> 5998 </div> 5999 } 6000 6001 @helper RenderTypeaheadSearch() 6002 { 6003 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar" 6004 data-page-size="5" 6005 data-search-feed-id="@impersonationFeed" 6006 data-result-page-id="@impersonationPageId" 6007 data-search-type="user-search" 6008 data-search-parameter-name="q"> 6009 6010 <div class="typeahead-search-field"> 6011 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")"> 6012 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ImpersonationSearchBarContent" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false"></ul> 6013 </div> 6014 </div> 6015 } 6016 6017 @helper RenderResultsList() 6018 { 6019 <ul id="ImpersonationBoxSearchResults" class="impersonation__search-results js-handlebars-root dw-mod" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false" data-preloader="minimal"></ul> 6020 } 6021 6022 @helper RenderSearchResultTemplate() 6023 { 6024 <script id="ImpersonationSearchResult" type="text/x-template"> 6025 {{#.}} 6026 {{#Users}} 6027 <li class="impersonation__search-results-item impersonation-user"> 6028 <form method="post" class="impersonation-user__form" name="account{{id}}"> 6029 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}"> 6030 <div class="impersonation-user__info"> 6031 <div class="impersonation-user__name">{{userName}}</div> 6032 <div class="impersonation-user__number">{{customerNumber}}</div> 6033 </div> 6034 @Render(new Button 6035 { 6036 ButtonType = ButtonType.Submit, 6037 ButtonLayout = ButtonLayout.Secondary, 6038 Title = Translate("Sign in as"), 6039 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "") 6040 }) 6041 </form> 6042 </li> 6043 {{/Users}} 6044 {{#unless Users}} 6045 <li class="impersonation__search-results-item impersonation__search-results-item--not-found"> 6046 @Translate("Your search gave 0 results") 6047 </li> 6048 {{/unless}} 6049 {{/.}} 6050 </script> 6051 } 6052 6053 @helper RenderSearchScripts() 6054 { 6055 <script> 6056 let inputDelayTimer; 6057 function searchKeyUpHandler(e) { 6058 clearTimeout(inputDelayTimer); 6059 let value = e.target.value; 6060 if (value != "") { 6061 inputDelayTimer = setTimeout(function () { 6062 updateResults(value); 6063 }, 500); 6064 } else { 6065 clearResults(); 6066 } 6067 }; 6068 6069 function updateResults(value) { 6070 if (value == "") { 6071 return null; 6072 } 6073 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value); 6074 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden"); 6075 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden"); 6076 } 6077 6078 function clearResults() { 6079 document.getElementById("ImpersonationBoxSearchField").value = ""; 6080 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults"); 6081 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden"); 6082 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden"); 6083 } 6084 </script> 6085 } 6086 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6087 6088 @using System 6089 @using System.Web 6090 @using System.Collections.Generic 6091 @using Dynamicweb.Rapido.Blocks.Extensibility 6092 @using Dynamicweb.Rapido.Blocks 6093 6094 @{ 6095 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master"); 6096 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table"; 6097 6098 Block orderLines = new Block 6099 { 6100 Id = "MiniCartOrderLines", 6101 SkipRenderBlocksList = true, 6102 BlocksList = new List<Block> 6103 { 6104 new Block { 6105 Id = "MiniCartOrderLinesList", 6106 SortId = 20, 6107 Template = RenderMiniCartOrderLinesList() 6108 } 6109 } 6110 }; 6111 6112 Block orderlinesScriptTemplates = new Block 6113 { 6114 Id = "OrderlinesScriptTemplates" 6115 }; 6116 6117 if (orderlinesView == "table") 6118 { 6119 orderLines.Template = RenderMiniCartOrderLinesTable(); 6120 orderLines.BlocksList.Add( 6121 new Block 6122 { 6123 Id = "MiniCartOrderlinesTableHeader", 6124 SortId = 10, 6125 Template = RenderMiniCartOrderLinesHeader() 6126 } 6127 ); 6128 6129 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates(); 6130 } 6131 else 6132 { 6133 orderLines.Template = RenderMiniCartOrderLinesBlocks(); 6134 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates(); 6135 } 6136 6137 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates); 6138 6139 Block miniCartScriptTemplates = new Block() 6140 { 6141 Id = "MasterMiniCartTemplates", 6142 SortId = 1, 6143 Template = RenderMiniCartScriptTemplates(), 6144 SkipRenderBlocksList = true, 6145 BlocksList = new List<Block> 6146 { 6147 orderLines, 6148 new Block { 6149 Id = "MiniCartFooter", 6150 Template = RenderMiniCartFooter(), 6151 SortId = 50, 6152 SkipRenderBlocksList = true, 6153 BlocksList = new List<Block> 6154 { 6155 new Block { 6156 Id = "MiniCartSubTotal", 6157 Template = RenderMiniCartSubTotal(), 6158 SortId = 30 6159 }, 6160 new Block { 6161 Id = "MiniCartFees", 6162 Template = RenderMiniCartFees(), 6163 SortId = 40 6164 }, 6165 new Block { 6166 Id = "MiniCartPoints", 6167 Template = RenderMiniCartPoints(), 6168 SortId = 50 6169 }, 6170 new Block { 6171 Id = "MiniCartTotal", 6172 Template = RenderMiniCartTotal(), 6173 SortId = 60 6174 }, 6175 new Block { 6176 Id = "MiniCartDisclaimer", 6177 Template = RenderMiniCartDisclaimer(), 6178 SortId = 70 6179 }, 6180 new Block { 6181 Id = "MiniCartActions", 6182 Template = RenderMiniCartActions(), 6183 SortId = 80 6184 } 6185 } 6186 } 6187 } 6188 }; 6189 6190 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates); 6191 } 6192 6193 @helper RenderMiniCartScriptsTableTemplates() 6194 { 6195 <script id="MiniCartOrderline" type="text/x-template"> 6196 {{#unless isEmpty}} 6197 <tr> 6198 <td class="u-w60px"><a href="{{link}}" class="{{hideimage}}"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=50&height=50&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}"></a></td> 6199 <td class="u-va-middle"> 6200 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a> 6201 {{#if variantname}} 6202 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a> 6203 {{/if}} 6204 {{#if unitname}} 6205 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div> 6206 {{/if}} 6207 </td> 6208 <td class="u-ta-right u-va-middle">{{quantity}}</td> 6209 <td class="u-ta-right u-va-middle"> 6210 {{#if pointsTotal}} 6211 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6212 {{else}} 6213 {{totalprice}} 6214 {{/if}} 6215 </td> 6216 </tr> 6217 {{/unless}} 6218 </script> 6219 6220 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6221 {{#unless isEmpty}} 6222 <tr class="table__row--no-border"> 6223 <td class="u-w60px">&nbsp;</td> 6224 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td> 6225 <td class="u-ta-right">&nbsp;</td> 6226 <td class="u-ta-right">{{totalprice}}</td> 6227 </tr> 6228 {{/unless}} 6229 </script> 6230 } 6231 6232 @helper RenderMiniCartScriptsListTemplates() 6233 { 6234 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 6235 6236 <script id="MiniCartOrderline" type="text/x-template"> 6237 {{#unless isEmpty}} 6238 <div class="mini-cart-orderline grid dw-mod"> 6239 <div class="grid__col-4"> 6240 <a href="{{link}}" class="{{hideimage}}"> 6241 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=100&height=100&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}"> 6242 </a> 6243 </div> 6244 <div class="grid__col-8"> 6245 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--truncate mini-cart-orderline__name--md u-padding-right--lg" title="{{name}}">{{name}}</a> 6246 {{#if variantname}} 6247 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div> 6248 {{/if}} 6249 {{#if unitname}} 6250 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div> 6251 {{/if}} 6252 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div> 6253 6254 <div class="grid__cell-footer"> 6255 <div class="grid__cell"> 6256 <div class="u-pull--left mini-cart-orderline__price dw-mod"> 6257 {{#if pointsTotal}} 6258 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6259 {{else}} 6260 {{totalprice}} 6261 {{/if}} 6262 </div> 6263 <button type="button" 6264 title="@Translate("Remove orderline")" 6265 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod" 6266 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button> 6267 </div> 6268 </div> 6269 </div> 6270 </div> 6271 {{/unless}} 6272 </script> 6273 6274 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6275 {{#unless isEmpty}} 6276 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod"> 6277 <div class="grid__col-4"> 6278 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div> 6279 </div> 6280 <div class="grid__col-8">{{totalprice}}</div> 6281 </div> 6282 {{/unless}} 6283 </script> 6284 } 6285 6286 @helper RenderMiniCartScriptTemplates() 6287 { 6288 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList(); 6289 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6290 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage")); 6291 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6292 6293 <script id="MiniCartContent" type="text/x-template"> 6294 {{#.}} 6295 {{#unless isEmpty}} 6296 @if (miniCartUseGoogleTagManager) 6297 { 6298 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 6299 } 6300 @RenderBlockList(subBlocks) 6301 {{/unless}} 6302 {{/.}} 6303 </script> 6304 } 6305 6306 @helper RenderMiniCartOrderLinesTable() 6307 { 6308 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6309 6310 <div class="u-overflow-auto"> 6311 <table class="table mini-cart-table dw-mod"> 6312 @RenderBlockList(subBlocks) 6313 </table> 6314 </div> 6315 } 6316 6317 @helper RenderMiniCartOrderLinesBlocks() 6318 { 6319 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6320 6321 <div class="u-overflow-auto"> 6322 @RenderBlockList(subBlocks) 6323 </div> 6324 } 6325 6326 @helper RenderMiniCartOrderLinesHeader() 6327 { 6328 <thead> 6329 <tr> 6330 <td>&nbsp;</td> 6331 <td>@Translate("Product")</td> 6332 <td class="u-ta-right">@Translate("Qty")</td> 6333 <td class="u-ta-right" width="120">@Translate("Price")</td> 6334 </tr> 6335 </thead> 6336 } 6337 6338 @helper RenderMiniCartOrderLinesList() 6339 { 6340 <text> 6341 {{#OrderLines}} 6342 {{#ifCond template "===" "CartOrderline"}} 6343 {{>MiniCartOrderline}} 6344 {{/ifCond}} 6345 {{#ifCond template "===" "CartOrderlineMobile"}} 6346 {{>MiniCartOrderline}} 6347 {{/ifCond}} 6348 {{#ifCond template "===" "CartOrderlineDiscount"}} 6349 {{>MiniCartOrderlineDiscount}} 6350 {{/ifCond}} 6351 {{/OrderLines}} 6352 </text> 6353 } 6354 6355 @helper RenderMiniCartFees() 6356 { 6357 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6358 if (!pointShop) 6359 { 6360 <text> 6361 {{#unless hidePaymentfee}} 6362 <div class="grid"> 6363 <div class="grid__col-6 grid__col--bleed-y"> 6364 {{paymentmethod}} 6365 </div> 6366 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div> 6367 </div> 6368 {{/unless}} 6369 </text> 6370 } 6371 <text> 6372 {{#unless hideShippingfee}} 6373 <div class="grid"> 6374 <div class="grid__col-6 grid__col--bleed-y"> 6375 {{shippingmethod}} 6376 </div> 6377 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div> 6378 </div> 6379 {{/unless}} 6380 </text> 6381 <text> 6382 {{#if hasTaxSettings}} 6383 <div class="grid"> 6384 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div> 6385 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div> 6386 </div> 6387 {{/if}} 6388 </text> 6389 } 6390 6391 @helper RenderMiniCartFooter() 6392 { 6393 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList(); 6394 6395 <div class="mini-cart__footer u-border-top u-padding-top dw-mod"> 6396 @RenderBlockList(subBlocks) 6397 </div> 6398 } 6399 6400 @helper RenderMiniCartActions() 6401 { 6402 int cartPageId = GetPageIdByNavigationTag("CartPage"); 6403 6404 <button type="button" title="@Translate("Empty cart")" class="btn btn--secondary u-full-width dw-mod u-no-margin u-margin-bottom" onclick="googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);">@Translate("Empty cart")</button> 6405 <a href="/Default.aspx?ID=@cartPageId" title="@Translate("Proceed to checkout")" class="btn btn--primary u-full-width u-no-margin dw-mod">@Translate("Proceed to checkout")</a> 6406 } 6407 6408 @helper RenderMiniCartPoints() 6409 { 6410 <text> 6411 {{#if earnings}} 6412 <div class="grid"> 6413 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div> 6414 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6415 <div> 6416 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points") 6417 </div> 6418 </div> 6419 </div> 6420 {{/if}} 6421 </text> 6422 } 6423 6424 @helper RenderMiniCartSubTotal() 6425 { 6426 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID); 6427 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6428 if (!pointShop) 6429 { 6430 <text> 6431 {{#unless hideSubTotal}} 6432 <div class="grid dw-mod u-bold"> 6433 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div> 6434 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6435 @if (hasTaxSettings) 6436 { 6437 <text>{{subtotalpricewithouttaxes}}</text> 6438 } 6439 else 6440 { 6441 <text>{{subtotalprice}}</text> 6442 } 6443 </div> 6444 </div> 6445 {{/unless}} 6446 </text> 6447 } 6448 } 6449 6450 @helper RenderMiniCartTotal() 6451 { 6452 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6453 6454 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod"> 6455 <div class="grid__col-6">@Translate("Total")</div> 6456 <div class="grid__col-6 grid--align-end"> 6457 <div> 6458 @if (pointShop) 6459 { 6460 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 6461 } 6462 else 6463 { 6464 <text>{{totalprice}}</text> 6465 } 6466 </div> 6467 </div> 6468 </div> 6469 } 6470 6471 @helper RenderMiniCartDisclaimer() 6472 { 6473 <text> 6474 {{#if showCheckoutDisclaimer}} 6475 <div class="grid u-margin-bottom u-ta-right"> 6476 <small class="grid__col-12">{{checkoutDisclaimer}}</small> 6477 </div> 6478 {{/if}} 6479 </text> 6480 } 6481 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6482 6483 @using Dynamicweb.Rapido.Blocks.Extensibility 6484 @using Dynamicweb.Rapido.Blocks 6485 @using Dynamicweb.Rapido.Blocks.Components.General 6486 @using Dynamicweb.Rapido.Blocks.Components 6487 @using Dynamicweb.Rapido.Services 6488 6489 @{ 6490 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : ""; 6491 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 6492 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 6493 6494 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType)) 6495 { 6496 if (addToCartNotificationType == "modal") 6497 { 6498 Block addToCartNotificationModal = new Block 6499 { 6500 Id = "AddToCartNotificationModal", 6501 Template = RenderAddToCartNotificationModal() 6502 }; 6503 6504 Block addToCartNotificationScript = new Block 6505 { 6506 Id = "AddToCartNotificationScript", 6507 Template = RenderAddToCartNotificationModalScript() 6508 }; 6509 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal); 6510 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 6511 } 6512 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 6513 { 6514 Block addToCartNotificationScript = new Block 6515 { 6516 Id = "AddToCartNotificationScript", 6517 Template = RenderAddToCartNotificationToggleScript() 6518 }; 6519 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 6520 } 6521 } 6522 } 6523 6524 @helper RenderAddToCartNotificationModal() 6525 { 6526 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div> 6527 } 6528 6529 @helper RenderAddToCartNotificationModalScript() 6530 { 6531 int cartPageId = GetPageIdByNavigationTag("CartPage"); 6532 6533 <script id="LastAddedProductTemplate" type="text/x-template"> 6534 @{ 6535 6536 Modal lastAddedProduct = new Modal 6537 { 6538 Id = "LastAddedProduct", 6539 Heading = new Heading 6540 { 6541 Level = 2, 6542 Title = Translate("Product is added to the cart") 6543 }, 6544 Width = ModalWidth.Md, 6545 BodyTemplate = RenderModalContent() 6546 }; 6547 6548 lastAddedProduct.AddActions( 6549 new Button 6550 { 6551 ButtonType = ButtonType.Button, 6552 ButtonLayout = ButtonLayout.Secondary, 6553 Title = Translate("Continue shopping"), 6554 CssClass = "u-pull--left u-no-margin btn--sm", 6555 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 6556 }, 6557 new Link 6558 { 6559 Href = "/Default.aspx?ID=" + cartPageId, 6560 ButtonLayout = ButtonLayout.Secondary, 6561 CssClass = "u-pull--right u-no-margin btn--sm", 6562 Title = Translate("Proceed to checkout") 6563 } 6564 ); 6565 6566 @Render(lastAddedProduct) 6567 } 6568 </script> 6569 <script> 6570 document.addEventListener('addToCart', function (event) { 6571 Cart.ShowLastAddedProductModal(event.detail); 6572 }); 6573 </script> 6574 } 6575 6576 @helper RenderModalContent() 6577 { 6578 <div class="grid"> 6579 <div class="grid__col-2"> 6580 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true }) 6581 </div> 6582 <div class="u-padding grid--align-self-center"> 6583 <span>{{quantity}}</span> x 6584 </div> 6585 <div class="grid__col-auto grid--align-self-center"> 6586 <div>{{productInfo.name}}</div> 6587 {{#if productInfo.variantName}} 6588 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small> 6589 {{/if}} 6590 {{#if productInfo.unitName}} 6591 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small> 6592 {{/if}} 6593 </div> 6594 </div> 6595 } 6596 6597 @helper RenderAddToCartNotificationToggleScript() 6598 { 6599 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 6600 6601 <script> 6602 document.addEventListener('addToCart', function () { 6603 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId'); 6604 }); 6605 </script> 6606 } 6607 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6608 6609 @using System 6610 @using System.Web 6611 @using System.Collections.Generic 6612 @using Dynamicweb.Rapido.Blocks.Extensibility 6613 @using Dynamicweb.Rapido.Blocks 6614 @using Dynamicweb.Rapido.Blocks.Components.General 6615 6616 @functions { 6617 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master"); 6618 } 6619 6620 @{ 6621 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content"); 6622 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content"); 6623 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content"); 6624 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header"); 6625 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header"); 6626 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header"); 6627 6628 Block masterFooterContent = new Block() 6629 { 6630 Id = "MasterFooterContent", 6631 SortId = 10, 6632 Template = RenderFooter(), 6633 SkipRenderBlocksList = true 6634 }; 6635 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent); 6636 6637 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader)) 6638 { 6639 Block masterFooterColumnOne = new Block 6640 { 6641 Id = "MasterFooterColumnOne", 6642 SortId = 10, 6643 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent), 6644 Design = new Design 6645 { 6646 Size = "auto", 6647 RenderType = RenderType.Column 6648 } 6649 }; 6650 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne); 6651 } 6652 6653 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader)) 6654 { 6655 Block masterFooterColumnTwo = new Block 6656 { 6657 Id = "MasterFooterColumnTwo", 6658 SortId = 20, 6659 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent), 6660 Design = new Design 6661 { 6662 Size = "auto", 6663 RenderType = RenderType.Column 6664 } 6665 }; 6666 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo); 6667 } 6668 6669 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader)) 6670 { 6671 Block masterFooterColumnThree = new Block 6672 { 6673 Id = "MasterFooterColumnThree", 6674 SortId = 30, 6675 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent), 6676 Design = new Design 6677 { 6678 Size = "auto", 6679 RenderType = RenderType.Column 6680 } 6681 }; 6682 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree); 6683 } 6684 6685 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp")) 6686 { 6687 Block masterFooterNewsletterSignUp = new Block 6688 { 6689 Id = "MasterFooterNewsletterSignUp", 6690 SortId = 40, 6691 Template = RenderFooterNewsletterSignUp(), 6692 Design = new Design 6693 { 6694 Size = "auto", 6695 RenderType = RenderType.Column 6696 } 6697 }; 6698 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp); 6699 } 6700 6701 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0) 6702 { 6703 Block masterFooterSocialLinks = new Block 6704 { 6705 Id = "MasterFooterSocialLinks", 6706 SortId = 50, 6707 Template = RenderFooterSocialLinks(), 6708 Design = new Design 6709 { 6710 Size = "auto", 6711 RenderType = RenderType.Column 6712 } 6713 }; 6714 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks); 6715 } 6716 6717 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0) 6718 { 6719 Block masterFooterPayments = new Block 6720 { 6721 Id = "MasterFooterPayments", 6722 SortId = 60, 6723 Template = RenderFooterPayments(), 6724 Design = new Design 6725 { 6726 Size = "12", 6727 RenderType = RenderType.Column 6728 } 6729 }; 6730 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments); 6731 } 6732 6733 Block masterFooterCopyright = new Block 6734 { 6735 Id = "MasterFooterCopyright", 6736 SortId = 70, 6737 Template = RenderFooterCopyright(), 6738 Design = new Design 6739 { 6740 Size = "12", 6741 RenderType = RenderType.Column 6742 } 6743 }; 6744 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright); 6745 } 6746 6747 @helper RenderFooter() 6748 { 6749 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList(); 6750 6751 <footer class="footer dw-mod"> 6752 <div class="center-container top-container__center-container dw-mod"> 6753 <div class="grid grid--external-bleed-x"> 6754 @RenderBlockList(subBlocks) 6755 </div> 6756 </div> 6757 </footer> 6758 } 6759 6760 @helper RenderFooterColumn(string header, string content) 6761 { 6762 <h3 class="footer__heading dw-mod">@header</h3> 6763 <div class="footer__content dw-mod"> 6764 @content 6765 </div> 6766 } 6767 6768 @helper RenderFooterNewsletterSignUp() 6769 { 6770 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString(); 6771 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart }; 6772 6773 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId }); 6774 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" }); 6775 form.Add(new TextField { 6776 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"), 6777 Type = TextFieldType.Email, 6778 ActionButton = new Button { 6779 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed" 6780 } 6781 }); 6782 6783 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3> 6784 <div class="footer__content dw-mod"> 6785 @Render(form) 6786 </div> 6787 } 6788 6789 @helper RenderFooterSocialLinks() 6790 { 6791 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3> 6792 <div class="footer__content dw-mod"> 6793 <div class="collection dw-mod"> 6794 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks")) 6795 { 6796 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 6797 string socialIconClass = socialIcon.SelectedValue; 6798 string socialIconTitle = socialIcon.SelectedName; 6799 string socialLink = socialitem.GetString("Link"); 6800 6801 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a> 6802 } 6803 </div> 6804 </div> 6805 } 6806 6807 @helper RenderFooterPayments() 6808 { 6809 <div class="footer__content dw-mod"> 6810 <div class="collection dw-mod"> 6811 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments")) 6812 { 6813 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel; 6814 string paymentImage = null; 6815 string paymentTitle = paymentItem.SelectedName; 6816 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault(); 6817 if (selected != null) 6818 { 6819 paymentImage = selected.Icon; 6820 } 6821 6822 <div class="footer__card-type"> 6823 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=60&Compression=75&image=@paymentImage" alt="@paymentTitle" title="@paymentTitle" /> 6824 </div> 6825 } 6826 </div> 6827 </div> 6828 } 6829 6830 @helper RenderFooterCopyright() 6831 { 6832 <div class="grid__col-12 footer__copyright dw-mod"> 6833 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p> 6834 </div> 6835 } 6836 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 6837 6838 @using System 6839 @using System.Web 6840 @using System.Collections.Generic 6841 @using Dynamicweb.Rapido.Blocks.Extensibility 6842 @using Dynamicweb.Rapido.Blocks 6843 @using Dynamicweb.Ecommerce.Common 6844 6845 @{ 6846 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master"); 6847 6848 Block masterScriptReferences = new Block() 6849 { 6850 Id = "MasterScriptReferences", 6851 SortId = 1, 6852 Template = RenderMasterScriptReferences() 6853 }; 6854 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences); 6855 } 6856 6857 @helper RenderMasterScriptReferences() { 6858 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script> 6859 <script src="/Files/Templates/Designs/Rapido/js/master.min.js"></script> 6860 6861 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript")) 6862 { 6863 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js"></script> 6864 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js"); 6865 } 6866 6867 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"); 6868 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js"); 6869 } 6870 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6871 6872 @using System 6873 @using System.Web 6874 @using System.Collections.Generic 6875 @using Dynamicweb.Rapido.Blocks.Extensibility 6876 @using Dynamicweb.Rapido.Blocks 6877 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 6878 @using Dynamicweb.Rapido.Services 6879 6880 @{ 6881 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master"); 6882 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 6883 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID")); 6884 6885 if (!navigationItemsHideSearch || isFavoriteList) 6886 { 6887 Block masterSearchScriptTemplates = new Block() 6888 { 6889 Id = "MasterSearchScriptTemplates", 6890 SortId = 1, 6891 Template = RenderSearchScriptTemplates() 6892 }; 6893 6894 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates); 6895 } 6896 } 6897 6898 @helper RenderSearchScriptTemplates() 6899 { 6900 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 6901 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 6902 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")); 6903 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID")); 6904 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults"); 6905 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton"); 6906 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton"); 6907 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton"); 6908 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6909 6910 <script id="SearchGroupsTemplate" type="text/x-template"> 6911 {{#.}} 6912 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li> 6913 {{/.}} 6914 </script> 6915 6916 <script id="SearchProductsTemplate" type="text/x-template"> 6917 {{#each .}} 6918 {{#Product}} 6919 {{#ifCond template "!==" "SearchMore"}} 6920 <li class="dropdown__item dropdown__item--seperator dw-mod"> 6921 @if (useFacebookPixel) 6922 { 6923 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text> 6924 } 6925 @if (useGoogleTagManager) 6926 { 6927 <text>{{{googleEnchantImpression googleImpression}}}</text> 6928 } 6929 <div> 6930 <a href="{{link}}" 6931 class="js-typeahead-link u-color-inherit u-pull--left" 6932 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 6933 title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 6934 <div class="u-margin-right u-pull--left {{noimage}} u-hidden-xs u-hidden-xxs"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=45&height=36&crop=5&FillCanvas=True&Compression=75&image={{image}}" alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"></div> 6935 <div class="u-pull--left"> 6936 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</div> 6937 @if (showPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 6938 { 6939 if (pointShopOnly) 6940 { 6941 <text> 6942 {{#if havePointPrice}} 6943 <div> 6944 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points") 6945 </div> 6946 {{else}} 6947 <small class="help-text u-no-margin">@Translate("Not available")</small> 6948 {{/if}} 6949 {{#unless canBePurchasedWithPoints}} 6950 {{#if havePointPrice}} 6951 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 6952 {{/if}} 6953 {{/unless}} 6954 </text> 6955 } 6956 else 6957 { 6958 <text>{{#ifCond priceDouble '>' 0}}</text> 6959 <div>{{price}}</div> 6960 <text>{{/ifCond}}</text> 6961 } 6962 } 6963 </div> 6964 </a> 6965 <div class="u-margin-left u-pull--right"> 6966 @{ 6967 var viewBtn = new Link 6968 { 6969 Href = "{{link}}", 6970 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 6971 ButtonLayout = ButtonLayout.Secondary, 6972 CssClass = "btn--condensed u-no-margin u-w80px js-ignore-click-outside", 6973 Title = Translate("View") 6974 }; 6975 } 6976 @if (showAddToCartButton && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 6977 { 6978 <text>{{#if hideAddToCartButton}}</text> 6979 @Render(viewBtn) 6980 <text>{{else}}</text> 6981 <text>{{#ifCond priceWithoutVAT '!==' '$0.00'}}</text> 6982 @Render(new AddToCartButton 6983 { 6984 HideTitle = true, 6985 ProductId = "{{productId}}", 6986 ProductInfo = "{{productInfo}}", 6987 BuyForPoints = pointShopOnly, 6988 OnClick = "{{facebookPixelAction}}", 6989 CssClass = "u-w80px u-no-margin js-ignore-click-outside", 6990 Icon = new Icon { 6991 CssClass = "js-ignore-click-outside" 6992 }, 6993 ExtraAttributes = new Dictionary<string, string> 6994 { 6995 { "{{disabledBuyButton}}", "" } 6996 } 6997 }) 6998 <text>{{else}}</text> 6999 @Render(viewBtn) 7000 <text>{{/ifCond}}</text> 7001 <text>{{/if}}</text> 7002 } 7003 else if (showViewButton) 7004 { 7005 @Render(viewBtn) 7006 } 7007 @if (showAddToDownloadButton) 7008 { 7009 <button type="button" class="btn btn--primary u-no-margin btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 7010 <i class="fas fa-plus js-button-icon"></i> 7011 </button> 7012 } 7013 </div> 7014 </div> 7015 </li> 7016 {{/ifCond}} 7017 {{#ifCond template "===" "SearchMore"}} 7018 {{>SearchMoreProducts}} 7019 {{/ifCond}} 7020 {{/Product}} 7021 {{else}} 7022 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7023 @Translate("Your search gave 0 results") 7024 </li> 7025 {{/each}} 7026 </script> 7027 7028 <script id="SearchMoreProducts" type="text/x-template"> 7029 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7030 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7031 @Translate("View all") 7032 </a> 7033 </li> 7034 </script> 7035 7036 <script id="SearchMorePages" type="text/x-template"> 7037 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7038 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7039 @Translate("View all") 7040 </a> 7041 </li> 7042 </script> 7043 7044 <script id="SearchPagesTemplate" type="text/x-template"> 7045 {{#each .}} 7046 {{#ifCond template "!==" "SearchMore"}} 7047 <li class="dropdown__item dropdown__item--seperator dropdown__item--no-padding dw-mod"> 7048 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link dropdown__link u-color-inherit"> 7049 <div class="u-margin-right"><i class="fa {{icon}} u-w20px u-ta-center"></i></div> 7050 <div class="u-bold u-truncate-text u-max-w220px js-typeahead-name">{{name}}</div> 7051 </a> 7052 </li> 7053 {{/ifCond}} 7054 {{#ifCond template "===" "SearchMore"}} 7055 {{>SearchMorePages}} 7056 {{/ifCond}} 7057 {{else}} 7058 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7059 @Translate("Your search gave 0 results") 7060 </li> 7061 {{/each}} 7062 </script> 7063 7064 <script id="SearchPagesTemplateWrap" type="text/x-template"> 7065 <div class="dropdown__column-header">@Translate("Pages")</div> 7066 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod"> 7067 {{>SearchPagesTemplate}} 7068 </ul> 7069 </script> 7070 7071 <script id="SearchProductsTemplateWrap" type="text/x-template"> 7072 <div class="dropdown__column-header">@Translate("Products")</div> 7073 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod"> 7074 {{>SearchProductsTemplate}} 7075 </ul> 7076 </script> 7077 } 7078 7079 @using Dynamicweb.Rapido.Blocks.Components 7080 @using Dynamicweb.Rapido.Blocks.Components.General 7081 @using Dynamicweb.Rapido.Blocks 7082 @using System.IO 7083 7084 7085 @using Dynamicweb.Rapido.Blocks.Components.General 7086 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7087 7088 7089 @* Component *@ 7090 7091 @helper RenderVariantMatrix(VariantMatrix settings) { 7092 if (settings != null) 7093 { 7094 int productLoopCounter = 0; 7095 int groupCount = 0; 7096 List<VariantOption> firstDimension = new List<VariantOption>(); 7097 List<VariantOption> secondDimension = new List<VariantOption>(); 7098 List<VariantOption> thirdDimension = new List<VariantOption>(); 7099 7100 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 7101 { 7102 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 7103 { 7104 if (groupCount == 0) { 7105 firstDimension.Add(variantOptions); 7106 } 7107 if (groupCount == 1) 7108 { 7109 secondDimension.Add(variantOptions); 7110 } 7111 if (groupCount == 2) 7112 { 7113 thirdDimension.Add(variantOptions); 7114 } 7115 } 7116 groupCount++; 7117 } 7118 7119 int rowCount = 0; 7120 int columnCount = 0; 7121 7122 <script> 7123 var variantsCollection = []; 7124 </script> 7125 7126 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 7127 @if (groupCount == 1) 7128 { 7129 <tbody> 7130 @foreach (VariantOption firstVariantOption in firstDimension) 7131 { 7132 var variantId = firstVariantOption.Id; 7133 <tr> 7134 <td class="u-bold"> 7135 @firstVariantOption.Name 7136 </td> 7137 <td> 7138 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7139 </td> 7140 </tr> 7141 productLoopCounter++; 7142 } 7143 7144 <tr> 7145 <td>&nbsp;</td> 7146 <td> 7147 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7148 </td> 7149 </tr> 7150 </tbody> 7151 } 7152 @if (groupCount == 2) 7153 { 7154 <thead> 7155 <tr> 7156 <td>&nbsp;</td> 7157 @foreach (VariantOption variant in secondDimension) 7158 { 7159 <td>@variant.Name</td> 7160 } 7161 </tr> 7162 </thead> 7163 <tbody> 7164 @foreach (VariantOption firstVariantOption in firstDimension) 7165 { 7166 string variantId = ""; 7167 columnCount = 0; 7168 7169 <tr> 7170 <td class="u-min-w120px">@firstVariantOption.Name</td> 7171 7172 @foreach (VariantOption secondVariantOption in secondDimension) 7173 { 7174 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 7175 <td> 7176 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7177 </td> 7178 7179 columnCount++; 7180 7181 productLoopCounter++; 7182 } 7183 7184 <td> 7185 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7186 </td> 7187 </tr> 7188 7189 rowCount++; 7190 } 7191 7192 @{ 7193 columnCount = 0; 7194 } 7195 7196 <tr> 7197 <td>&nbsp;</td> 7198 @foreach (VariantOption secondVariantOption in secondDimension) 7199 { 7200 <td> 7201 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7202 </td> 7203 7204 columnCount++; 7205 } 7206 <td>&nbsp;</td> 7207 </tr> 7208 </tbody> 7209 } 7210 @if (groupCount == 3) 7211 { 7212 <thead> 7213 <tr> 7214 <td>&nbsp;</td> 7215 @foreach (VariantOption thirdVariantOption in thirdDimension) 7216 { 7217 <td>@thirdVariantOption.Name</td> 7218 } 7219 </tr> 7220 </thead> 7221 <tbody> 7222 @foreach (VariantOption firstVariantOption in firstDimension) 7223 { 7224 int colspan = (thirdDimension.Count + 1); 7225 7226 <tr> 7227 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 7228 </tr> 7229 7230 foreach (VariantOption secondVariantOption in secondDimension) 7231 { 7232 string variantId = ""; 7233 columnCount = 0; 7234 7235 <tr> 7236 <td class="u-min-w120px">@secondVariantOption.Name</td> 7237 7238 @foreach (VariantOption thirdVariantOption in thirdDimension) 7239 { 7240 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 7241 7242 <td> 7243 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7244 </td> 7245 7246 columnCount++; 7247 productLoopCounter++; 7248 } 7249 7250 <td> 7251 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7252 </td> 7253 </tr> 7254 rowCount++; 7255 } 7256 } 7257 7258 @{ 7259 columnCount = 0; 7260 } 7261 7262 <tr> 7263 <td>&nbsp;</td> 7264 @foreach (VariantOption thirdVariantOption in thirdDimension) 7265 { 7266 <td> 7267 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7268 </td> 7269 7270 columnCount++; 7271 } 7272 <td>&nbsp;</td> 7273 </tr> 7274 </tbody> 7275 } 7276 </table> 7277 7278 <script> 7279 document.addEventListener("DOMContentLoaded", function (event) { 7280 MatrixUpdateQuantity("@settings.ProductId"); 7281 }); 7282 7283 MatrixUpdateQuantity = function (productId) { 7284 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 7285 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 7286 7287 var qtyRowArr = []; 7288 var qtyColumnArr = []; 7289 7290 var totalQty = 0; 7291 7292 for (var i = 0; i < allQtyFields.length; i++) { 7293 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 7294 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 7295 } 7296 7297 for (var i = 0; i < allQtyFields.length; i++) { 7298 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 7299 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 7300 totalQty += parseFloat(allQtyFields[i].value); 7301 } 7302 7303 //Update row counters 7304 for (var i = 0; i < qtyRowArr.length; i++) { 7305 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7306 7307 if (qtyRowArr[i] != undefined && qtyCounter != null) { 7308 var currentCount = qtyCounter.innerHTML; 7309 qtyCounter.innerHTML = qtyRowArr[i]; 7310 7311 if (currentCount != qtyCounter.innerHTML) { 7312 qtyCounter.classList.add("qty-field--active"); 7313 } 7314 } 7315 7316 } 7317 7318 //Update column counters 7319 for (var i = 0; i < qtyColumnArr.length; i++) { 7320 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7321 7322 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 7323 var currentCount = qtyCounter.innerHTML; 7324 qtyCounter.innerHTML = qtyColumnArr[i]; 7325 7326 if (currentCount != qtyCounter.innerHTML) { 7327 qtyCounter.classList.add("qty-field--active"); 7328 } 7329 } 7330 } 7331 7332 if (document.getElementById("TotalQtyCount_" + productId)) { 7333 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 7334 } 7335 7336 //Clean up animations 7337 setTimeout(function () { 7338 for (var i = 0; i < qtyRowArr.length; i++) { 7339 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7340 if (qtyCounter != null) { 7341 qtyCounter.classList.remove("qty-field--active"); 7342 } 7343 } 7344 for (var i = 0; i < qtyColumnArr.length; i++) { 7345 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7346 if (qtyCounter != null) { 7347 qtyCounter.classList.remove("qty-field--active"); 7348 } 7349 } 7350 }, 1000); 7351 } 7352 </script> 7353 } 7354 } 7355 7356 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 7357 { 7358 string loopCount = productLoopCounter.ToString(); 7359 7360 bool combinationFound = false; 7361 double stock = 0; 7362 double quantityValue = 0; 7363 string note = ""; 7364 7365 VariantProduct variantProduct = null; 7366 7367 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 7368 { 7369 stock = variantProduct.Stock; 7370 quantityValue = variantProduct.Quantity; 7371 combinationFound = true; 7372 } 7373 7374 if (combinationFound) 7375 { 7376 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 7377 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 7378 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 7379 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 7380 <input type="number" name="Quantity@(loopCount)" id="Quantity_@(settings.ProductId)_@variantId" value="@quantityValue" min="0" class="js-qty u-no-margin u-full-max-width" style="width: 100%; max-width: 100%" onkeyup="MatrixUpdateQuantity('@settings.ProductId')" onmouseup="MatrixUpdateQuantity('@settings.ProductId')" data-qty-row-group="@rowCount" data-qty-column-group="@columnCount"> 7381 7382 if (stock != 0) 7383 { 7384 <small>@Translate("Stock") @stock</small> 7385 } 7386 7387 <script> 7388 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 7389 variantsCollection.push(variants); 7390 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 7391 </script> 7392 } 7393 else 7394 { 7395 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 7396 } 7397 } 7398 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7399 7400 @* Component *@ 7401 7402 @helper RenderAddToCart(AddToCart settings) 7403 { 7404 //set Id for quantity selector to get it's value from button 7405 if (settings.QuantitySelector != null) 7406 { 7407 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 7408 { 7409 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 7410 } 7411 7412 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 7413 7414 if (settings.Disabled) 7415 { 7416 settings.QuantitySelector.Disabled = true; 7417 } 7418 7419 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 7420 { 7421 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 7422 } 7423 } 7424 7425 if (settings.Disabled) 7426 { 7427 settings.AddButton.Disabled = true; 7428 } 7429 7430 settings.AddButton.CssClass += " btn--condensed"; 7431 7432 //unitsSelector 7433 if (settings.UnitSelector != null) 7434 { 7435 if (settings.Disabled) 7436 { 7437 settings.QuantitySelector.Disabled = true; 7438 } 7439 } 7440 7441 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 7442 @if (settings.UnitSelector != null) 7443 { 7444 @Render(settings.UnitSelector) 7445 } 7446 @if (settings.QuantitySelector != null) 7447 { 7448 @Render(settings.QuantitySelector) 7449 } 7450 @Render(settings.AddButton) 7451 </div> 7452 } 7453 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7454 7455 @* Component *@ 7456 7457 @helper RenderAddToCartButton(AddToCartButton settings) 7458 { 7459 if (!settings.HideTitle) 7460 { 7461 if (string.IsNullOrEmpty(settings.Title)) 7462 { 7463 if (settings.BuyForPoints) 7464 { 7465 settings.Title = Translate("Buy with points"); 7466 } 7467 else 7468 { 7469 settings.Title = Translate("Add to cart"); 7470 } 7471 } 7472 } 7473 else 7474 { 7475 settings.Title = ""; 7476 } 7477 7478 if (settings.Icon == null) 7479 { 7480 settings.Icon = new Icon(); 7481 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 7482 } 7483 7484 if (string.IsNullOrEmpty(settings.Icon.Name)) 7485 { 7486 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 7487 } 7488 7489 settings.OnClick = "Cart.AddToCart(event, { " + 7490 "id: '" + settings.ProductId + "'," + 7491 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 7492 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 7493 (settings.BuyForPoints ? "buyForPoints: true," : "") + 7494 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 7495 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 7496 "});" + settings.OnClick; 7497 7498 @RenderButton(settings) 7499 } 7500 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7501 7502 @* Component *@ 7503 7504 @helper RenderUnitSelector(UnitSelector settings) 7505 { 7506 if (string.IsNullOrEmpty(settings.Id)) 7507 { 7508 settings.Id = Guid.NewGuid().ToString("N"); 7509 } 7510 var disabledClass = settings.Disabled ? "disabled" : ""; 7511 7512 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 7513 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 7514 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 7515 <div class="dropdown__content dw-mod"> 7516 @settings.OptionsContent 7517 </div> 7518 <label class="dropdown-trigger-off" for="@settings.Id"></label> 7519 </div> 7520 } 7521 @using System.Reflection 7522 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7523 7524 @* Component *@ 7525 7526 @helper RenderQuantitySelector(QuantitySelector settings) 7527 { 7528 var attributes = new Dictionary<string, string>(); 7529 7530 /*base settings*/ 7531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 7532 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 7533 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 7534 if (settings.Disabled) { attributes.Add("disabled", "true"); } 7535 if (settings.Required) { attributes.Add("required", "true"); } 7536 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 7537 /*end*/ 7538 7539 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 7540 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 7541 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 7542 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 7543 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 7544 if (settings.Min == null) { settings.Min = 1; } 7545 attributes.Add("min", settings.Min.ToString()); 7546 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 7547 if (settings.Value == null) { settings.Value = 1; } 7548 attributes.Add("value", settings.Value.ToString()); 7549 attributes.Add("type", "number"); 7550 7551 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7552 7553 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 7554 } 7555 @using Dynamicweb.Rapido.Blocks.Components 7556 7557 @using Dynamicweb.Frontend 7558 @using Dynamicweb.Frontend.Devices 7559 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7560 @using Dynamicweb.Rapido.Blocks.Components.General 7561 @using System.Collections.Generic; 7562 7563 @* Component *@ 7564 7565 @helper RenderCustomerCenterList(CustomerCenterList settings) 7566 { 7567 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 7568 string hideActions = isTouchDevice ? "u-block" : ""; 7569 7570 <table class="table data-list dw-mod"> 7571 @if (settings.GetHeaders().Length > 0) { 7572 <thead> 7573 <tr class="u-bold"> 7574 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 7575 { 7576 var attributes = new Dictionary<string, string>(); 7577 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 7578 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 7579 attributes.Add("align", header.Align.ToString()); 7580 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7581 7582 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 7583 } 7584 </tr> 7585 </thead> 7586 } 7587 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 7588 { 7589 int columnCount = 0; 7590 int totalColumns = listItem.GetInfoItems().Length; 7591 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-acions" : ""; 7592 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 7593 7594 var attributes = new Dictionary<string, string>(); 7595 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 7596 7597 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7598 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 7599 <tr> 7600 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 7601 <td rowspan="2" onclick="@listItem.OnClick" class="data-list__main-item dw-mod"> 7602 @if (!string.IsNullOrEmpty(listItem.Title)) { 7603 <div class="u-bold">@listItem.Title</div> 7604 } 7605 @if (!string.IsNullOrEmpty(listItem.Description)) { 7606 <div>@listItem.Description</div> 7607 } 7608 </td> 7609 } 7610 7611 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 7612 { 7613 var infoAttributes = new Dictionary<string, string>(); 7614 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 7615 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 7616 infoAttributes.Add("align", infoItem.Align.ToString()); 7617 7618 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7619 string columnClick = columnCount < (totalColumns-1) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 7620 7621 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 7622 @if (!string.IsNullOrEmpty(infoItem.Title)) { 7623 <div>@infoItem.Title</div> 7624 } 7625 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 7626 <div><small>@infoItem.Subtitle</small></div> 7627 } 7628 </td> 7629 7630 columnCount++; 7631 } 7632 </tr> 7633 <tr> 7634 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 7635 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 7636 @foreach (ButtonBase action in listItem.GetActions()) 7637 { 7638 action.ButtonLayout = ButtonLayout.LinkClean; 7639 action.CssClass += " data-list__action-button link"; 7640 7641 @Render(action) 7642 } 7643 </div> 7644 </td> 7645 </tr> 7646 </tbody> 7647 } 7648 </table> 7649 } 7650 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 7651 7652 @using System 7653 @using System.Web 7654 @using System.Collections.Generic 7655 @using Dynamicweb.Rapido.Blocks.Extensibility 7656 @using Dynamicweb.Rapido.Blocks 7657 7658 @{ 7659 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 7660 7661 Block primaryBottomSnippets = new Block() 7662 { 7663 Id = "MasterJavascriptInitializers", 7664 SortId = 100, 7665 Template = RenderPrimaryBottomSnippets() 7666 }; 7667 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets); 7668 } 7669 7670 @helper RenderPrimaryBottomSnippets() 7671 { 7672 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode"); 7673 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 7674 7675 if (isWireframeMode) 7676 { 7677 <script> 7678 Wireframe.Init(true); 7679 </script> 7680 } 7681 7682 7683 if (useGoogleTagManager) 7684 { 7685 <script> 7686 document.addEventListener('addToCart', function(event) { 7687 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 7688 if (typeof googleImpression == "string") { 7689 googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 7690 } 7691 dataLayer.push({ 7692 'event': 'addToCart', 7693 'ecommerce': { 7694 'currencyCode': googleImpression.currency, 7695 'add': { 7696 'products': [{ 7697 'name': googleImpression.name, 7698 'id': googleImpression.id, 7699 'price': googleImpression.price, 7700 'brand': googleImpression.brand, 7701 'category': googleImpression.category, 7702 'variant': googleImpression.variant, 7703 'quantity': event.detail.quantity 7704 }] 7705 } 7706 } 7707 }); 7708 }); 7709 </script> 7710 } 7711 7712 //if digitalwarehouse 7713 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart")) 7714 { 7715 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]); 7716 7717 if (string.IsNullOrEmpty(cartContextId)) 7718 { 7719 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2"); 7720 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps); 7721 cartContextId = cartSettings.OrderContextID; 7722 HttpContext.Current.Application["DownloadCartContext"] = cartContextId; 7723 } 7724 7725 <script> 7726 let downloadCart = new DownloadCart({ 7727 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"), 7728 contextId: "@cartContextId", 7729 addButtonText: "@Translate("Add")", 7730 removeButtonText: "@Translate("Remove")" 7731 }); 7732 </script> 7733 } 7734 7735 <!--$$Javascripts--> 7736 } 7737 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 7738 7739 @using System 7740 @using System.Web 7741 @using System.Collections.Generic 7742 @using Dynamicweb.Rapido.Blocks 7743 7744 @{ 7745 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master"); 7746 7747 } 7748 7749 7750 @functions { 7751 public class ManifestIcon 7752 { 7753 public string src { get; set; } 7754 public string type { get; set; } 7755 public string sizes { get; set; } 7756 } 7757 7758 public class Manifest 7759 { 7760 public string name { get; set; } 7761 public string short_name { get; set; } 7762 public string start_url { get; set; } 7763 public string display { get; set; } 7764 public string background_color { get; set; } 7765 public string theme_color { get; set; } 7766 public List<ManifestIcon> icons { get; set; } 7767 } 7768 } 7769 7770 <!DOCTYPE html> 7771 7772 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 7773 7774 7775 7776 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 7777 @RenderBlockList(masterPage.BlocksRoot.BlocksList) 7778 7779 7780 7781 @helper RenderMasterHead() { 7782 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList(); 7783 7784 <head> 7785 <!-- Rapido version 3.2.1 --> 7786 7787 @RenderBlockList(subBlocks) 7788 </head> 7789 } 7790 7791 @helper RenderMasterMetadata() { 7792 var swatches = new Dynamicweb.Content.Items.ColorSwatchService(); 7793 var brandColors = swatches.GetColorSwatch(1); 7794 string brandColorOne = brandColors.Palette["BrandColor1"]; 7795 7796 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null) { 7797 Manifest manifest = new Manifest 7798 { 7799 name = Model.Area.Item.GetItem("Settings").GetString("AppName"), 7800 short_name = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppShortName")) ? Model.Area.Item.GetItem("Settings").GetString("AppShortName") : Model.Area.Item.GetItem("Settings").GetString("AppName"), 7801 start_url = "/", 7802 display = "standalone", 7803 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"), 7804 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor") 7805 }; 7806 7807 manifest.icons = new List<ManifestIcon> { 7808 new ManifestIcon { 7809 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 7810 sizes = "192x192", 7811 type = "image/png" 7812 }, 7813 new ManifestIcon { 7814 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 7815 sizes = "512x512", 7816 type = "image/png" 7817 }, 7818 new ManifestIcon { 7819 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 7820 sizes = "1024x1024", 7821 type = "image/png" 7822 } 7823 }; 7824 7825 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json"); 7826 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest); 7827 string currentManifest = File.ReadAllText(manifestFilePath); 7828 7829 if (manifestJSON != currentManifest) 7830 { 7831 File.WriteAllText(manifestFilePath, manifestJSON); 7832 } 7833 } 7834 7835 <meta charset="utf-8" /> 7836 <title>@Model.Title</title> 7837 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7838 <meta name="robots" content="index, follow"> 7839 <meta name="theme-color" content="@brandColorOne" /> 7840 7841 if (!Model.MetaTags.Contains("og:image")) { 7842 Pageview.Meta.AddTag("og:image", string.Format("{0}://{1}{2}", Dynamicweb.Context.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, Model.PropertyItem.GetFile("OpenGraphImage"))); 7843 } 7844 7845 if (!Model.MetaTags.Contains("og:description")) { 7846 Pageview.Meta.AddTag("og:description", Model.Description); 7847 } 7848 7849 Pageview.Meta.AddTag("og:title", Model.Title); 7850 Pageview.Meta.AddTag("og:site_name", Model.Name); 7851 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString()); 7852 Pageview.Meta.AddTag("og:type", "Website"); 7853 Pageview.Meta.AddTag("fb:page_id", Model.ID.ToString()); 7854 7855 @Model.MetaTags 7856 } 7857 7858 @helper RenderMasterCss() { 7859 var fonts = new string[] { 7860 getFontFamily("Layout", "HeaderFont"), 7861 getFontFamily("Layout", "SubheaderFont"), 7862 getFontFamily("Layout", "TertiaryHeaderFont"), 7863 getFontFamily("Layout", "BodyText"), 7864 getFontFamily("Layout", "Header", "ToolsFont"), 7865 getFontFamily("Layout", "Header", "NavigationFont"), 7866 getFontFamily("Layout", "MobileNavigation", "Font"), 7867 getFontFamily("ProductList", "Facets", "HeaderFont"), 7868 getFontFamily("ProductPage", "PriceFontDesign"), 7869 getFontFamily("Ecommerce", "SaleSticker", "Font"), 7870 getFontFamily("Ecommerce", "NewSticker", "Font"), 7871 getFontFamily("Ecommerce", "CustomSticker", "Font") 7872 }; 7873 7874 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks; 7875 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png"; 7876 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro"); 7877 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css"; 7878 if (useFontAwesomePro) 7879 { 7880 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css"; 7881 } 7882 7883 //Favicon 7884 <link href="@favicon" rel="icon" type="image/png"> 7885 7886 //Base (Default, wireframe) styles 7887 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css"> 7888 7889 //Rapido Css from Website Settings 7890 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css"> 7891 7892 //Ignite Css (Custom site specific styles) 7893 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css?v=1.1"> 7894 7895 //Font awesome 7896 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css"> 7897 7898 //Flag icon 7899 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css"> 7900 7901 //Google fonts 7902 var family = string.Join("%7C", fonts.Where(x => !string.IsNullOrEmpty(x)).Distinct().Select(x => string.Format("{0}:100,200,300,400,500,600,700,800,900", x))); 7903 7904 <link href="https://fonts.googleapis.com/css?family=@family" rel="stylesheet"> 7905 7906 PushPromise(favicon); 7907 PushPromise(fontAwesomeCssLink); 7908 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css"); 7909 PushPromise(autoCssLink); 7910 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css"); 7911 PushPromise("/Files/Images/placeholder.gif"); 7912 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css"); 7913 } 7914 7915 @helper RenderMasterManifest() { 7916 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName"))) 7917 { 7918 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json"> 7919 PushPromise("/Files/Templates/Designs/Rapido/manifest.json"); 7920 } 7921 } 7922 7923 @helper RenderMasterBody() { 7924 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList(); 7925 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 7926 if (!String.IsNullOrEmpty(designLayout)) { 7927 designLayout = "class=\"" + designLayout + "\""; 7928 } 7929 7930 <body @designLayout> 7931 @RenderBlockList(subBlocks) 7932 </body> 7933 } 7934 7935 @helper RenderMasterHeader() 7936 { 7937 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList(); 7938 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 7939 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : ""; 7940 7941 <header class="top-container @stickyTop dw-mod" id="Top"> 7942 @RenderBlockList(subBlocks) 7943 </header> 7944 } 7945 7946 @helper RenderMain() 7947 { 7948 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList(); 7949 7950 <main class="site dw-mod"> 7951 @RenderBlockList(subBlocks) 7952 </main> 7953 } 7954 7955 @helper RenderPageContent() 7956 { 7957 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 7958 string pagePos = isNavigationStickyMenu ? "js-page-pos" : ""; 7959 7960 <div id="Page" class="page @pagePos"> 7961 <section class="center-container content-container dw-mod" id="content"> 7962 7963 @RenderSnippet("Content") 7964 </section> 7965 </div> 7966 } 7967 7968 @* Hack to support nested helpers *@ 7969 @SnippetStart("Content") 7970 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 7971 7972 7973 @using Dynamicweb.Extensibility 7974 @using Dynamicweb.Core 7975 @using Dynamicweb.Rapido.Blocks.Components 7976 @using Dynamicweb.Rapido.Blocks.Components.Articles 7977 @using Dynamicweb.Rapido.Blocks.Components.General 7978 @using Dynamicweb.Rapido.Blocks 7979 @using Dynamicweb.Content.Items 7980 7981 @functions { 7982 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle"); 7983 7984 public string GetParentSettingsItem(string systemName) { 7985 string item = null; 7986 7987 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID); 7988 while (current != null && current.Parent != current) { 7989 var temp = current.Item != null ? current.Item[systemName] : ""; 7990 7991 if (temp != null) { 7992 item = temp.ToString(); 7993 7994 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) { 7995 break; 7996 } 7997 } 7998 7999 current = current.Parent; 8000 } 8001 8002 return item; 8003 } 8004 8005 public string GetArticleCategory(int pageId) 8006 { 8007 string categoryName = null; 8008 8009 //Secure that the article is not in the root folder = Actual has a category 8010 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8011 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8012 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8013 { 8014 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName(); 8015 } 8016 } 8017 } 8018 8019 return categoryName; 8020 } 8021 8022 public string GetArticleCategoryColor(int pageId) 8023 { 8024 string categoryColor = ""; 8025 8026 //Secure that the article is not in the root folder = Actual has a category 8027 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8028 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8029 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8030 { 8031 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null) 8032 { 8033 var service = new ColorSwatchService(); 8034 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString(); 8035 8036 if (!categoryColor.Contains("#")) { 8037 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor); 8038 } 8039 } 8040 } 8041 } 8042 } 8043 8044 return categoryColor; 8045 } 8046 } 8047 8048 @{ 8049 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed")); 8050 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString(); 8051 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default"; 8052 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout; 8053 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default"; 8054 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout; 8055 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default"; 8056 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout; 8057 8058 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12"; 8059 string contentColumns = textLayout != "full" ? "8" : "12"; 8060 8061 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0; 8062 8063 ArticleHeaderLayout headerLayout; 8064 8065 switch (topLayout) 8066 { 8067 case "default": 8068 headerLayout = ArticleHeaderLayout.Clean; 8069 break; 8070 case "split": 8071 headerLayout = ArticleHeaderLayout.Split; 8072 break; 8073 case "banner": 8074 headerLayout = ArticleHeaderLayout.Banner; 8075 break; 8076 case "overlay": 8077 headerLayout = ArticleHeaderLayout.Overlay; 8078 break; 8079 default: 8080 headerLayout = ArticleHeaderLayout.Clean; 8081 break; 8082 } 8083 8084 8085 Block articleContainer = new Block 8086 { 8087 Id = "ArticleContainer", 8088 SortId = 10, 8089 Design = new Design 8090 { 8091 RenderType = RenderType.Row 8092 }, 8093 BlocksList = new List<Block> { 8094 new Block { 8095 Id = "ArticleBody", 8096 SortId = 30, 8097 Design = new Design { 8098 RenderType = RenderType.Column, 8099 Size = "12", 8100 HidePadding = true 8101 } 8102 } 8103 } 8104 }; 8105 articlePage.Add(articleContainer); 8106 8107 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary; 8108 8109 switch (Model.Item.GetString("ButtonDesign")) { 8110 case "primary": 8111 topBannerButtonLayout = ButtonLayout.Primary; 8112 break; 8113 case "secondary": 8114 topBannerButtonLayout = ButtonLayout.Secondary; 8115 break; 8116 case "teritary": 8117 topBannerButtonLayout = ButtonLayout.Tertiary; 8118 break; 8119 case "link": 8120 topBannerButtonLayout = ButtonLayout.Link; 8121 break; 8122 } 8123 8124 ArticleHeader topBanner = new ArticleHeader 8125 { 8126 Layout = headerLayout, 8127 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } }, 8128 Heading = Model.Item.GetString("Title"), 8129 Subheading = Model.Item.GetString("Summary"), 8130 TextColor = "#fff", 8131 Author = Model.Item.GetString("Author"), 8132 Date = Model.Item.GetString("Date"), 8133 Category = GetArticleCategory(Model.ID), 8134 CategoryColor = GetArticleCategoryColor(Model.ID), 8135 Link = Model.Item.GetString("Link"), 8136 LinkText = Model.Item.GetString("LinkText"), 8137 ButtonLayout = topBannerButtonLayout, 8138 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0, 8139 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0, 8140 ExternalParagraphId = externalParagraphId 8141 }; 8142 8143 Block articleTop = new Block 8144 { 8145 Id = "ArticleHead", 8146 SortId = 20, 8147 Component = topBanner, 8148 Design = new Design 8149 { 8150 RenderType = RenderType.Column, 8151 Size = "12", 8152 HidePadding = true, 8153 CssClass = "article-head" 8154 } 8155 }; 8156 articlePage.Add("ArticleContainer", articleTop); 8157 8158 8159 Block articleBodyRow = new Block 8160 { 8161 Id = "ArticleBodyRow", 8162 SortId = 10, 8163 SkipRenderBlocksList = true 8164 }; 8165 articlePage.Add("ArticleBody", articleBodyRow); 8166 8167 8168 if (Model.Item.GetString("Paragraphs") != null) 8169 { 8170 int count = 0; 8171 foreach (var paragraph in Model.Item.GetItems("Paragraphs")) 8172 { 8173 if (!paragraph.GetBoolean("RenderAsQuote")) 8174 { 8175 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default"; 8176 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap; 8177 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 8178 8179 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>") 8180 { 8181 string firstLetter = paragraph.GetString("Text").Substring(3, 1); 8182 text = paragraph.GetString("Text").Remove(3, 1); 8183 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>"); 8184 } 8185 8186 if (paragraph.GetFile("Image") != null) 8187 { 8188 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : ""; 8189 8190 Block articleParagraphImage = new Block 8191 { 8192 Id = "ArticleParagraph" + count + "Image", 8193 SortId = (count * 10), 8194 Design = new Design 8195 { 8196 RenderType = RenderType.Column, 8197 Size = imageColumns, 8198 CssClass = "u-color-light--bg u-padding--lg" 8199 } 8200 }; 8201 8202 if (imageLayout == "banner") 8203 { 8204 ArticleBanner banner = new ArticleBanner 8205 { 8206 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") }, 8207 Heading = imageTitle, 8208 UseFilters = false 8209 }; 8210 articleParagraphImage.Component = banner; 8211 } 8212 else 8213 { 8214 ArticleImage image = new ArticleImage 8215 { 8216 Image = new Image 8217 { 8218 Path = paragraph.GetFile("Image"), 8219 Title = imageTitle, 8220 ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, 8221 Caption = paragraph.GetString("ImageCaption") 8222 } 8223 }; 8224 articleParagraphImage.Component = image; 8225 } 8226 8227 articlePage.Add("ArticleBodyRow", articleParagraphImage); 8228 } 8229 8230 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL"))) 8231 { 8232 Block articleParagraphVideo = new Block 8233 { 8234 Id = "ArticleParagraph" + count + "Video", 8235 SortId = (count * 10) + 1, 8236 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" }, 8237 Design = new Design 8238 { 8239 RenderType = RenderType.Column, 8240 Size = imageColumns, 8241 CssClass = "u-color-light--bg u-padding--lg" 8242 } 8243 }; 8244 articlePage.Add("ArticleBodyRow", articleParagraphVideo); 8245 } 8246 8247 if (!String.IsNullOrEmpty(paragraph.GetString("Heading"))) 8248 { 8249 Block articleParagraphHeader = new Block 8250 { 8251 Id = "ArticleParagraph" + count + "Heading", 8252 SortId = (count * 10) + 2, 8253 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") }, 8254 Design = new Design 8255 { 8256 RenderType = RenderType.Column, 8257 Size = contentColumns, 8258 CssClass = "u-color-light--bg u-padding--lg" 8259 } 8260 }; 8261 articlePage.Add("ArticleBodyRow", articleParagraphHeader); 8262 } 8263 8264 if (!String.IsNullOrEmpty(text)) 8265 { 8266 Block articleParagraphText = new Block 8267 { 8268 Id = "ArticleParagraph" + count + "Text", 8269 SortId = (count * 10) + 3, 8270 Component = new ArticleText { Text = text }, 8271 Design = new Design 8272 { 8273 RenderType = RenderType.Column, 8274 Size = contentColumns, 8275 CssClass = "u-color-light--bg u-padding--lg" 8276 } 8277 }; 8278 8279 articlePage.Add("ArticleBodyRow", articleParagraphText); 8280 } 8281 } 8282 else 8283 { 8284 if (!String.IsNullOrEmpty(paragraph.GetString("Text"))) 8285 { 8286 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 8287 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : ""; 8288 8289 Block articleParagraphQuote = new Block 8290 { 8291 Id = "ArticleParagraph" + count + "Quote", 8292 SortId = (count * 10) + 3, 8293 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor }, 8294 Design = new Design 8295 { 8296 RenderType = RenderType.Column, 8297 Size = contentColumns, 8298 CssClass = "u-color-light--bg u-padding--lg" 8299 } 8300 }; 8301 articlePage.Add("ArticleBodyRow", articleParagraphQuote); 8302 } 8303 } 8304 8305 count++; 8306 } 8307 } 8308 8309 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout }; 8310 8311 8312 //Related 8313 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default"; 8314 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices; 8315 8316 if (showRelatedArtices == "true") 8317 { 8318 Block articleRelated = new Block 8319 { 8320 Id = "ArticleRelated", 8321 SortId = 30, 8322 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() }, 8323 Design = new Design 8324 { 8325 RenderType = RenderType.Column, 8326 Size = "12" 8327 } 8328 }; 8329 articlePage.Add("ArticleContainer", articleRelated); 8330 } 8331 } 8332 8333 8334 @using System 8335 @using System.Web 8336 @using System.Collections.Generic 8337 @using Dynamicweb.Rapido.Blocks 8338 8339 @{ 8340 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle"); 8341 8342 } 8343 8344 8345 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 8346 @RenderBlockList(articlePage.BlocksRoot.BlocksList) 8347 @SnippetEnd("Content") 8348 8349 </html> 8350 8351