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_d8523753160d4a0798c4e8fbaf4c24ac.Execute() in D:\dynamicweb.net\Solutions\42Digital\megatrade_prod\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8326
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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