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_d7b2b558d96144f997678e541adaea67.Execute() in D:\dynamicweb.net\Solutions\42Digital\megatrade_prod\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8399
   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>> @using System @using System.Web @using System.Collections.Generic @using Dynamicweb.Rapido.Blocks @using Dynamicweb.Rapido.Blocks.Extensibility @using Dynamicweb.Security.UserManagement @using Dynamicweb.Security.UserManagement.ExternalAuthentication @using Dynamicweb.Rapido.Blocks.Components.General @{ BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master"); Block loginModal = new Block() { Id = "LoginModal", SortId = 10, Component = new Modal { Id = "SignIn", Heading = new Heading { Level = 0, Title = Translate("Sign in") }, Width = ModalWidth.Sm, BodyTemplate = RenderLoginForm() } }; loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal); } @helper RenderLoginForm() { int pageId = Model.TopPage.ID; string userSignedInErrorText = ""; int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Model.LogOnFailed; bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); ProviderCollection providers = Provider.GetActiveProviders(); if (Model.LogOnFailed) { switch (Model.LogOnFailedReason) { case LogOnFailedReason.PasswordLengthInvalid: userSignedInErrorText = Translate("Password length is invalid"); break; case LogOnFailedReason.IncorrectLogin: userSignedInErrorText = Translate("Invalid email or password"); break; case LogOnFailedReason.ExceededFailedLogOnLimit: userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked"); break; case LogOnFailedReason.LoginLocked: userSignedInErrorText = Translate("The user account is temporarily locked"); break; case LogOnFailedReason.PasswordExpired: userSignedInErrorText = Translate("The password has expired and needs to be renewed"); break; default: userSignedInErrorText = Translate("An unknown error occured"); break; } } Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm" }; TextField passwordField = new TextField { Id = "login-password", Type = TextFieldType.Password, Name = "password", Label = Translate("Password"), Required = true }; if (!hideForgotPasswordLink) { passwordField.Link = new Link { Title = Translate("Forgot password?"), Href = "/Default.aspx?id=" + signInProfilePageId + "&LoginAction=Recovery" }; } form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) }); form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" }); form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" }); form.Add(new HiddenField { Name = "LoginAction", Value = "Login" }); form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Megatrade User Email"), CssClass = "u-full-width", Required = true }); form.Add(passwordField); form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error }); form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") }); form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" }); foreach (Provider LoginProvider in providers) { var ProviderName = LoginProvider.Name.ToLower(); form.Add(new Link { Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID, Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After }, ButtonLayout = ButtonLayout.LinkClean, CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName, AltText = ProviderName }); } if (!hideCreateAccountLink) { form.Add(new Text { Content = "<div class=\"u-border-top u-full-width u-margin-bottom--lg\"></div>" }); form.Add(new Link { Href = "/Default.aspx?id=" + createAccountPageId, ButtonLayout = ButtonLayout.LinkClean, Title = Translate("Create account"), CssClass = "u-full-width u-ta-center" }); } @Render(form) if (showModalOnStart) { <script> document.getElementById("SignInModalTrigger").checked = true; </script> } } @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") { <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3194 3195 @using System 3196 @using System.Web 3197 @using System.Collections.Generic 3198 @using Dynamicweb.Rapido.Blocks.Extensibility 3199 @using Dynamicweb.Rapido.Blocks 3200 @using Dynamicweb.Rapido.Services 3201 3202 3203 @functions { 3204 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3205 } 3206 3207 @{ 3208 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"; 3209 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 3210 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed(); 3211 3212 Block mobileHeader = new Block() 3213 { 3214 Id = "MobileTop", 3215 SortId = 10, 3216 Template = RenderMobileTop(), 3217 SkipRenderBlocksList = true 3218 }; 3219 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader); 3220 3221 Block mobileHeaderNavigation = new Block() 3222 { 3223 Id = "MobileHeaderNavigation", 3224 SortId = 10, 3225 Template = RenderMobileHeaderNavigation(), 3226 SkipRenderBlocksList = true, 3227 BlocksList = new List<Block> { 3228 new Block { 3229 Id = "MobileHeaderNavigationTrigger", 3230 SortId = 10, 3231 Template = RenderMobileHeaderNavigationTrigger() 3232 } 3233 } 3234 }; 3235 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation); 3236 3237 Block mobileHeaderLogo = new Block() 3238 { 3239 Id = "MobileHeaderLogo", 3240 SortId = 20, 3241 Template = RenderMobileHeaderLogo(), 3242 SkipRenderBlocksList = true 3243 }; 3244 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo); 3245 3246 Block mobileHeaderActions = new Block() 3247 { 3248 Id = "MobileHeaderActions", 3249 SortId = 30, 3250 Template = RenderMobileTopActions(), 3251 SkipRenderBlocksList = true 3252 }; 3253 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions); 3254 3255 if (!mobileHideSearch) 3256 { 3257 Block mobileHeaderSearch = new Block 3258 { 3259 Id = "MobileHeaderSearch", 3260 SortId = 10, 3261 Template = RenderMobileTopSearch() 3262 }; 3263 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch); 3264 } 3265 3266 Block mobileHeaderMiniCart; 3267 3268 if (!mobileHideCart) 3269 { 3270 mobileHeaderMiniCart = new Block 3271 { 3272 Id = "MobileHeaderMiniCart", 3273 SortId = 20, 3274 Template = RenderMobileTopMiniCart() 3275 }; 3276 3277 Block miniCartCounterScriptTemplate = new Block 3278 { 3279 Id = "MiniCartCounterScriptTemplate", 3280 Template = RenderMobileMiniCartCounterContent() 3281 }; 3282 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 3283 } 3284 else 3285 { 3286 mobileHeaderMiniCart = new Block 3287 { 3288 Id = "MobileHeaderMiniCart", 3289 SortId = 20 3290 }; 3291 } 3292 3293 if (!mobileHideSearch) 3294 { 3295 Block mobileHeaderSearchBar = new Block() 3296 { 3297 Id = "MobileHeaderSearchBar", 3298 SortId = 30, 3299 Template = RenderMobileTopSearchBar() 3300 }; 3301 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar); 3302 } 3303 3304 switch (mobileTopLayout) 3305 { 3306 case "nav-left": 3307 mobileHeaderNavigation.SortId = 10; 3308 mobileHeaderLogo.SortId = 20; 3309 mobileHeaderActions.SortId = 30; 3310 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3311 break; 3312 case "nav-right": 3313 mobileHeaderLogo.SortId = 10; 3314 mobileHeaderActions.SortId = 20; 3315 mobileHeaderNavigation.SortId = 30; 3316 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3317 break; 3318 case "nav-search-left": 3319 mobileHeaderNavigation.SortId = 10; 3320 mobileHeaderLogo.SortId = 20; 3321 mobileHeaderActions.SortId = 30; 3322 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3323 break; 3324 case "search-left": 3325 mobileHeaderActions.SortId = 10; 3326 mobileHeaderLogo.SortId = 20; 3327 mobileHeaderNavigation.SortId = 30; 3328 mobileHeaderMiniCart.SortId = 0; 3329 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3330 break; 3331 } 3332 } 3333 3334 3335 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3336 3337 @using System 3338 @using System.Web 3339 @using Dynamicweb.Rapido.Blocks.Extensibility 3340 @using Dynamicweb.Rapido.Blocks 3341 3342 @{ 3343 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3344 } 3345 3346 3347 3348 3349 @helper RenderMobileTop() { 3350 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList(); 3351 3352 <nav class="main-navigation-mobile dw-mod"> 3353 <div class="center-container top-container__center-container dw-mod"> 3354 <div class="grid grid--align-center"> 3355 @RenderBlockList(subBlocks) 3356 </div> 3357 </div> 3358 </nav> 3359 } 3360 3361 @helper RenderMobileHeaderNavigation() { 3362 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList(); 3363 3364 <div class="grid__col-auto-width"> 3365 <ul class="menu dw-mod"> 3366 @RenderBlockList(subBlocks) 3367 </ul> 3368 </div> 3369 } 3370 3371 @helper RenderMobileHeaderNavigationTrigger() { 3372 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3373 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label> 3374 </li> 3375 } 3376 3377 @helper RenderMobileHeaderLogo() { 3378 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList(); 3379 3380 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"; 3381 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : ""; 3382 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 3383 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName"); 3384 3385 string mobileLogo = "/Files/Images/logo-dynamicweb.png"; 3386 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null) 3387 { 3388 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded; 3389 } 3390 3391 if (Path.GetExtension(mobileLogo).ToLower() != ".svg") 3392 { 3393 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&amp;width=100&amp;crop=5&amp;Compression=75&amp;image=" + mobileLogo; 3394 } 3395 else 3396 { 3397 mobileLogo = HttpUtility.UrlDecode(mobileLogo); 3398 } 3399 3400 <div class="grid__col-auto grid__col--bleed"> 3401 <div class="grid__cell @centeredLogo"> 3402 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod"> 3403 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" /> 3404 </a> 3405 </div> 3406 3407 @RenderBlockList(subBlocks) 3408 </div> 3409 } 3410 3411 @helper RenderMobileTopActions() { 3412 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList(); 3413 3414 <div class="grid__col-auto-width"> 3415 <ul class="menu dw-mod"> 3416 @RenderBlockList(subBlocks) 3417 </ul> 3418 </div> 3419 } 3420 3421 @helper RenderMobileTopSearch() { 3422 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3423 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 3424 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 3425 </label> 3426 </li> 3427 } 3428 3429 @helper RenderMobileTopMiniCart() { 3430 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3431 int cartPageId = GetPageIdByNavigationTag("CartPage"); 3432 double cartProductsCount = Model.Cart.TotalProductsCount; 3433 3434 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper"> 3435 <div class="mini-cart dw-mod"> 3436 <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"> 3437 <div class="u-inline u-position-relative"> 3438 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i> 3439 <div class="mini-cart__counter dw-mod"> 3440 <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"> 3441 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount"> 3442 @cartProductsCount 3443 </div> 3444 </div> 3445 </div> 3446 </div> 3447 </a> 3448 </div> 3449 </li> 3450 } 3451 3452 @helper RenderMobileTopSearchBar() 3453 { 3454 string searchFeedId = ""; 3455 string searchSecondFeedId = ""; 3456 int groupsFeedId; 3457 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 3458 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 3459 string resultPageLink; 3460 string searchPlaceholder; 3461 string searchType = "product-search"; 3462 string searchTemplate; 3463 string searchContentTemplate = ""; 3464 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 3465 bool showGroups = true; 3466 3467 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch") 3468 { 3469 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 3470 resultPageLink = contentSearchPageLink; 3471 searchPlaceholder = Translate("Search page"); 3472 groupsFeedId = 0; 3473 searchType = "content-search"; 3474 searchTemplate = "SearchPagesTemplate"; 3475 showGroups = false; 3476 } 3477 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch") 3478 { 3479 searchFeedId = productsPageId + "&feed=true"; 3480 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 3481 resultPageLink = Converter.ToString(productsPageId); 3482 searchPlaceholder = Translate("Search products or pages"); 3483 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 3484 searchType = "combined-search"; 3485 searchTemplate = "SearchProductsTemplateWrap"; 3486 searchContentTemplate = "SearchPagesTemplateWrap"; 3487 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 3488 } 3489 else 3490 { 3491 resultPageLink = Converter.ToString(productsPageId); 3492 searchFeedId = productsPageId + "&feed=true"; 3493 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 3494 searchPlaceholder = Translate("Search products"); 3495 searchTemplate = "SearchProductsTemplate"; 3496 searchType = "product-search"; 3497 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 3498 } 3499 3500 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" /> 3501 3502 <div class="main-navigation-mobile typeahead-mobile dw-mod"> 3503 <div class="center-container top-container__center-container dw-mod"> 3504 <div class="grid"> 3505 <div class="grid__col-auto"> 3506 <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"> 3507 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue"> 3508 @if (string.IsNullOrEmpty(searchSecondFeedId)) 3509 { 3510 <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> 3511 } 3512 else 3513 { 3514 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid"> 3515 <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> 3516 <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> 3517 </div> 3518 } 3519 <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> 3520 </div> 3521 </div> 3522 <div class="grid__col-auto-width"> 3523 <ul class="menu dw-mod"> 3524 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3525 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 3526 <i class="fas fa-times fa-1_5x"></i> 3527 </label> 3528 </li> 3529 </ul> 3530 </div> 3531 </div> 3532 </div> 3533 </div> 3534 } 3535 3536 @helper RenderMobileMiniCartCounterContent() 3537 { 3538 <script id="MiniCartCounterContent" type="text/x-template"> 3539 {{#.}} 3540 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 3541 {{numberofproducts}} 3542 </div> 3543 {{/.}} 3544 </script> 3545 } 3546 </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 productUrl = Dynamicweb.Frontend.PageView.Current().SearchFriendlyUrl; string dkShopUrl = "produkter"; string enShopUrl = "products"; string flagCurrent = "flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(Dynamicweb.Frontend.PageView.Current().AreaID).EcomCountryCode.ToLower(); 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="@flagCurrent 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) { if (Dynamicweb.Frontend.PageView.Current().AreaID != Dynamicweb.Services.Areas.GetArea(lang.ID).ID) { string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.EnglishName, @" ?\(.*?\)", string.Empty); var langNameDA = Translate(cultureName); cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1); string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + Translate(cultureName); var redirectUrl = "/Default.aspx?ID=" + lang.Page.ID; //var redirectUrl = "/Default.aspx?AreaID=" + Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID; if (productUrl.Contains(dkShopUrl) || productUrl.Contains(enShopUrl)) { if (lang.IsMaster) { redirectUrl = productUrl.Replace(enShopUrl, dkShopUrl); } else { redirectUrl = productUrl.Replace(dkShopUrl, enShopUrl); } } <li class="menu-mobile__item dw-mod"> <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod menu-mobile__link--level-1" href="@redirectUrl">@langInfo</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> 3547 3548 @using System 3549 @using System.Web 3550 @using Dynamicweb.Rapido.Blocks.Extensibility 3551 @using Dynamicweb.Rapido.Blocks 3552 3553 @{ 3554 Block masterDesktopLogo = new Block 3555 { 3556 Id = "MasterDesktopLogo", 3557 SortId = 10, 3558 Template = RenderDesktopLogo(), 3559 Design = new Design 3560 { 3561 Size = "auto-width", 3562 HidePadding = true, 3563 RenderType = RenderType.Column, 3564 CssClass = "grid--align-self-center" 3565 } 3566 }; 3567 3568 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo); 3569 } 3570 3571 3572 @helper RenderDesktopLogo() 3573 { 3574 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 3575 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 3576 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : ""; 3577 alignClass = topLayout == "splitted-center" ? "u-middle" : alignClass; 3578 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png"; 3579 if (Path.GetExtension(logo).ToLower() != ".svg") 3580 { 3581 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight"); 3582 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40; 3583 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&amp;crop=5&amp;Compression=75&amp;image=" + logo; 3584 } 3585 else 3586 { 3587 logo = HttpUtility.UrlDecode(logo); 3588 } 3589 3590 <div class="logo @alignClass dw-mod"> 3591 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block"> 3592 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" /> 3593 </a> 3594 </div> 3595 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3596 3597 @using System 3598 @using System.Web 3599 @using Dynamicweb.Rapido.Blocks.Extensibility 3600 @using Dynamicweb.Rapido.Blocks 3601 3602 @functions { 3603 bool isMegaMenu; 3604 } 3605 3606 @{ 3607 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false; 3608 Block masterDesktopMenu = new Block 3609 { 3610 Id = "MasterDesktopMenu", 3611 SortId = 10, 3612 Template = RenderDesktopMenu(), 3613 Design = new Design 3614 { 3615 Size = "auto", 3616 HidePadding = true, 3617 RenderType = RenderType.Column 3618 } 3619 }; 3620 3621 if (isMegaMenu) 3622 { 3623 masterDesktopMenu.Design.CssClass = "u-reset-position"; 3624 } 3625 3626 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu); 3627 } 3628 3629 @helper RenderDesktopMenu() 3630 { 3631 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 3632 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : ""; 3633 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout; 3634 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : ""; 3635 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 3636 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders"); 3637 int startLevel = renderPagesInToolBar ? 1 : 0; 3638 3639 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink"); 3640 3641 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment"> 3642 @if (!isMegaMenu) 3643 { 3644 @RenderNavigation(new 3645 { 3646 id = "topnavigation", 3647 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 3648 startLevel = startLevel, 3649 ecomStartLevel = startLevel + 1, 3650 endlevel = 5, 3651 expandmode = "all", 3652 template = "BaseMenuWithDropdown.xslt" 3653 }); 3654 } 3655 else 3656 { 3657 @RenderNavigation(new 3658 { 3659 id = "topnavigation", 3660 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap topnavigation grid--justify-space-between", 3661 startLevel = startLevel, 3662 ecomStartLevel = startLevel + 1, 3663 endlevel = 5, 3664 promotionImage = megamenuPromotionImage, 3665 promotionLink = promotionLink, 3666 expandmode = "all", 3667 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(), 3668 template = "BaseMegaMenu.xslt" 3669 }); 3670 } 3671 </div> 3672 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3673 3674 @using System 3675 @using System.Web 3676 @using Dynamicweb.Rapido.Blocks.Extensibility 3677 @using Dynamicweb.Rapido.Blocks 3678 3679 @{ 3680 Block masterDesktopActionsMenu = new Block 3681 { 3682 Id = "MasterDesktopActionsMenu", 3683 SortId = 10, 3684 Template = RenderDesktopActionsMenu(), 3685 Design = new Design 3686 { 3687 CssClass = "u-flex" 3688 }, 3689 SkipRenderBlocksList = true 3690 3691 }; 3692 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu); 3693 3694 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"))) 3695 { 3696 Block masterDesktopActionsHeaderButton = new Block 3697 { 3698 Id = "MasterDesktopActionsHeaderButton", 3699 SortId = 60, 3700 Template = RenderHeaderButton() 3701 }; 3702 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton); 3703 } 3704 } 3705 3706 @helper RenderDesktopActionsMenu() 3707 { 3708 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList(); 3709 3710 <ul class="menu u-flex dw-mod"> 3711 @RenderBlockList(subBlocks) 3712 </ul> 3713 } 3714 3715 @helper RenderHeaderButton() 3716 { 3717 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText"); 3718 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"); 3719 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : ""; 3720 3721 <li class="menu__item menu__item--horizontal menu--clean dw-mod"> 3722 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-left" href="@headerButtonLink">@headerButtonText</a> 3723 </li> 3724 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> @using System @using System.Web @using Dynamicweb.Core; @using System.Text.RegularExpressions @using Dynamicweb.Rapido.Blocks.Extensibility @using Dynamicweb.Rapido.Blocks @{ Block masterDesktopActionsMenuLanguageSelector = new Block { Id = "MasterDesktopActionsMenuLanguageSelector", SortId = 40, Template = RenderLanguageSelector() }; BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector); } @helper RenderLanguageSelector() { 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--clean"; string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 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() : ""; if (Model.Languages.Count > 1) { string productUrl = Dynamicweb.Frontend.PageView.Current().SearchFriendlyUrl; string dkShopUrl = "produkter"; string enShopUrl = "products"; <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod"> <div class="@menuLinkClass dw-mod" title="@Translate("Language")"> @*<i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i>*@ @{ string flagCurrent = "flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(Dynamicweb.Frontend.PageView.Current().AreaID).EcomCountryCode.ToLower(); } <i class="@flagCurrent"></i> </div> <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell"> @foreach (var lang in Model.Languages) { if (Dynamicweb.Frontend.PageView.Current().AreaID != Dynamicweb.Services.Areas.GetArea(lang.ID).ID) { string widthClass = "menu__item--fixed-width"; string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name; 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); var pageID = Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID; if (languageViewType == "flag-culture") { langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + langNameDA; } if (languageViewType == "flag") { langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>"; widthClass = ""; } if (languageViewType == "name") { langInfo = lang.Name; } if (languageViewType == "culture") { langInfo = cultureName; widthClass = ""; } var redirectUrl = "/Default.aspx?ID=" + lang.Page.ID; //var redirectUrl = "/Default.aspx?AreaID=" + Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID; if (productUrl.Contains(dkShopUrl) || productUrl.Contains(enShopUrl)) { if (lang.IsMaster) { redirectUrl = productUrl.Replace(enShopUrl, dkShopUrl); } else { redirectUrl = productUrl.Replace(dkShopUrl, enShopUrl); } } <div class="menu__item dw-mod @widthClass"> <a href="@redirectUrl" class="menu-dropdown__link dw-mod">@langInfo</a> </div> } @*<div class="menu__item dw-mod @widthClass"> <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a> </div>*@ } </div> </li> } } @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> 3725 3726 @using System 3727 @using System.Web 3728 @using Dynamicweb.Rapido.Blocks.Extensibility 3729 @using Dynamicweb.Rapido.Blocks 3730 3731 @{ 3732 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites"); 3733 3734 Block masterDesktopActionsMenuFavorites = new Block 3735 { 3736 Id = "MasterDesktopActionsMenuFavorites", 3737 SortId = 30, 3738 Template = RenderFavorites() 3739 }; 3740 3741 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0) 3742 { 3743 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites); 3744 } 3745 } 3746 3747 @helper RenderFavorites() 3748 { 3749 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 3750 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId; 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 liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 3754 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 3755 3756 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 3757 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")"> 3758 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i> 3759 </a> 3760 </li> 3761 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3762 3763 @using System 3764 @using System.Web 3765 @using Dynamicweb.Rapido.Blocks.Extensibility 3766 @using Dynamicweb.Rapido.Blocks 3767 @using Dynamicweb.Rapido.Services 3768 3769 @{ 3770 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 3771 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 3772 3773 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart) 3774 { 3775 Block masterDesktopActionsMenuMiniCart = new Block 3776 { 3777 Id = "MasterDesktopActionsMenuMiniCart", 3778 SortId = 60, 3779 Template = RenderMiniCart(miniCartLayout == "dropdown"), 3780 SkipRenderBlocksList = true, 3781 BlocksList = new List<Block>() 3782 }; 3783 3784 Block miniCartCounterScriptTemplate = new Block 3785 { 3786 Id = "MiniCartCounterScriptTemplate", 3787 Template = RenderMiniCartCounterContent() 3788 }; 3789 3790 //dropdown layout is default 3791 RazorEngine.Templating.TemplateWriter layoutTemplate; 3792 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate; 3793 3794 switch (miniCartLayout) 3795 { 3796 case "dropdown": 3797 layoutTemplate = RenderMiniCartDropdownLayout(); 3798 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 3799 break; 3800 case "panel": 3801 layoutTemplate = RenderMiniCartPanelLayout(); 3802 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 3803 break; 3804 case "modal": 3805 layoutTemplate = RenderMiniCartModalLayout(); 3806 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 3807 break; 3808 case "none": 3809 default: 3810 layoutTemplate = RenderMiniCartDropdownLayout(); 3811 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 3812 break; 3813 } 3814 3815 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 3816 { 3817 Id = "MiniCartTrigger", 3818 Template = miniCartTriggerTemplate 3819 }); 3820 3821 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 3822 { 3823 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 3824 { 3825 Id = "MiniCartLayout", 3826 Template = layoutTemplate 3827 }); 3828 } 3829 3830 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart); 3831 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 3832 } 3833 3834 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3835 { 3836 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block { 3837 Id = "CartInitialization" 3838 }); 3839 } 3840 } 3841 3842 @helper RenderMiniCart(bool hasMouseEnterEvent) 3843 { 3844 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList(); 3845 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 3846 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean"; 3847 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3848 string mouseEvent = ""; 3849 string id = "MiniCart"; 3850 if (hasMouseEnterEvent) 3851 { 3852 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\""; 3853 id = "miniCartTrigger"; 3854 } 3855 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent> 3856 @RenderBlockList(subBlocks) 3857 </li> 3858 } 3859 3860 @helper RenderMiniCartTriggerLabel() 3861 { 3862 int cartPageId = GetPageIdByNavigationTag("CartPage"); 3863 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 3864 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 3865 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 3866 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3867 3868 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")"> 3869 <div class="u-inline u-position-relative"> 3870 <i class="@cartIcon fa-1_5x"></i> 3871 @RenderMiniCartCounter() 3872 </div> 3873 </div> 3874 } 3875 3876 @helper RenderMiniCartTriggerLink() 3877 { 3878 int cartPageId = GetPageIdByNavigationTag("CartPage"); 3879 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 3880 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 3881 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 3882 3883 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")"> 3884 <span class="u-inline u-position-relative"> 3885 <i class="@cartIcon fa-1_5x"></i> 3886 @RenderMiniCartCounter() 3887 </span> 3888 </a> 3889 } 3890 3891 @helper RenderMiniCartCounter() 3892 { 3893 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3894 string cartProductsCount = Model.Cart.TotalProductsCount.ToString(); 3895 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 3896 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 3897 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : ""; 3898 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : ""; 3899 3900 if (showPrice && counterPosition == "right") 3901 { 3902 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")"; 3903 } 3904 3905 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod"> 3906 <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"> 3907 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()"> 3908 @cartProductsCount @cartProductsTotalPrice 3909 </span> 3910 </span> 3911 </span> 3912 } 3913 3914 @helper RenderMiniCartCounterContent() 3915 { 3916 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 3917 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 3918 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice; 3919 3920 <script id="MiniCartCounterContent" type="text/x-template"> 3921 {{#.}} 3922 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 3923 @if (showPriceInMiniCartCounter) 3924 { 3925 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text> 3926 } 3927 else 3928 { 3929 <text>{{numberofproducts}}</text> 3930 } 3931 </span> 3932 {{/.}} 3933 </script> 3934 } 3935 3936 @helper RenderMiniCartDropdownLayout() 3937 { 3938 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3939 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 3940 3941 <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"> 3942 <div class="mini-cart-dropdown__inner dw-mod"> 3943 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3> 3944 <div class="mini-cart-dropdown__body u-flex dw-mod"> 3945 <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> 3946 </div> 3947 </div> 3948 </div> 3949 } 3950 3951 @helper RenderMiniCartPanelLayout() 3952 { 3953 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3954 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 3955 3956 <div class="mini-cart grid__cell dw-mod"> 3957 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" /> 3958 <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"> 3959 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label> 3960 <div class="panel__content u-full-width dw-mod"> 3961 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3> 3962 <div class="panel__content-body panel__content-body--cart dw-mod"> 3963 <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> 3964 </div> 3965 </div> 3966 </div> 3967 </div> 3968 } 3969 3970 @helper RenderMiniCartModalLayout() 3971 { 3972 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 3973 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 3974 3975 <div class="mini-cart grid__cell dw-mod"> 3976 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" /> 3977 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 3978 <label for="miniCartTrigger" class="modal-overlay"></label> 3979 <div class="modal modal--md modal--top-right dw-mod"> 3980 <div class="modal__body u-flex grid--direction-column dw-mod"> 3981 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3> 3982 <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> 3983 </div> 3984 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label> 3985 </div> 3986 </div> 3987 </div> 3988 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3989 3990 @using System 3991 @using System.Web 3992 @using Dynamicweb.Rapido.Blocks.Extensibility 3993 @using Dynamicweb.Rapido.Blocks 3994 3995 @{ 3996 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon"); 3997 3998 Block masterDesktopActionsMenuOrderDraft = new Block 3999 { 4000 Id = "MasterDesktopActionsMenuOrderDraft", 4001 SortId = 40, 4002 Template = RenderOrderDraft() 4003 }; 4004 4005 if (showOrderDraftLink && Model.CurrentUser.ID > 0) 4006 { 4007 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft); 4008 } 4009 } 4010 4011 @helper RenderOrderDraft() 4012 { 4013 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft"); 4014 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId; 4015 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 4016 4017 4018 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4019 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 4020 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4021 4022 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 4023 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")"> 4024 <span class="u-inline u-position-relative"> 4025 <i class="@draftIcon fa-1_5x"></i> 4026 </span> 4027 </a> 4028 </li> 4029 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4030 4031 @using System 4032 @using System.Web 4033 @using Dynamicweb.Rapido.Blocks.Extensibility 4034 @using Dynamicweb.Rapido.Blocks 4035 4036 @{ 4037 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"); 4038 4039 Block masterDesktopActionsMenuDownloadCart = new Block 4040 { 4041 Id = "MasterDesktopActionsMenuDownloadCart", 4042 SortId = 50, 4043 Template = RenderDownloadCart() 4044 }; 4045 4046 if (showDownloadCartLink && Model.CurrentUser.ID > 0) 4047 { 4048 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart); 4049 } 4050 } 4051 4052 @helper RenderDownloadCart() 4053 { 4054 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart"); 4055 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId; 4056 4057 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4058 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 4059 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4060 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 4061 4062 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 4063 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")"> 4064 <span class="u-inline u-position-relative"> 4065 <i class="fas fa-cart-arrow-down fa-1_5x"></i> 4066 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span> 4067 </span> 4068 </a> 4069 </li> 4070 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4071 4072 @using System 4073 @using System.Web 4074 @using Dynamicweb.Rapido.Blocks.Extensibility 4075 @using Dynamicweb.Rapido.Blocks 4076 4077 @functions { 4078 public class SearchConfiguration 4079 { 4080 public string searchFeedId { get; set; } 4081 public string searchSecondFeedId { get; set; } 4082 public int groupsFeedId { get; set; } 4083 public string resultPageLink { get; set; } 4084 public string searchPlaceholder { get; set; } 4085 public string searchType { get; set; } 4086 public string searchTemplate { get; set; } 4087 public string searchContentTemplate { get; set; } 4088 public string searchValue { get; set; } 4089 public bool showGroups { get; set; } 4090 4091 public SearchConfiguration() 4092 { 4093 searchFeedId = ""; 4094 searchSecondFeedId = ""; 4095 searchType = "product-search"; 4096 searchContentTemplate = ""; 4097 showGroups = true; 4098 } 4099 } 4100 } 4101 @{ 4102 Block masterSearchBar = new Block 4103 { 4104 Id = "MasterSearchBar", 4105 SortId = 40, 4106 Template = RenderSearch("bar"), 4107 Design = new Design 4108 { 4109 Size = "auto", 4110 HidePadding = true, 4111 RenderType = RenderType.Column 4112 } 4113 }; 4114 4115 Block masterSearchAction = new Block 4116 { 4117 Id = "MasterDesktopActionsMenuSearch", 4118 SortId = 10, 4119 Template = RenderSearch() 4120 }; 4121 4122 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar); 4123 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction); 4124 } 4125 4126 @helper RenderSearch(string type = "mini-search") 4127 { 4128 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage")); 4129 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 4130 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch"; 4131 4132 SearchConfiguration searchConfiguration = null; 4133 4134 switch (searchType) { 4135 case "contentSearch": 4136 searchConfiguration = new SearchConfiguration() { 4137 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 4138 resultPageLink = contentSearchPageLink, 4139 searchPlaceholder = Translate("Search page"), 4140 groupsFeedId = 0, 4141 searchType = "content-search", 4142 searchTemplate = "SearchPagesTemplate", 4143 showGroups = false 4144 }; 4145 break; 4146 case "combinedSearch": 4147 searchConfiguration = new SearchConfiguration() { 4148 searchFeedId = productsPageId + "&feed=true", 4149 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 4150 resultPageLink = Converter.ToString(productsPageId), 4151 searchPlaceholder = Translate("Search products or pages"), 4152 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 4153 searchType = "combined-search", 4154 searchTemplate = "SearchProductsTemplateWrap", 4155 searchContentTemplate = "SearchPagesTemplateWrap", 4156 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 4157 }; 4158 break; 4159 default: //productSearch 4160 searchConfiguration = new SearchConfiguration() { 4161 resultPageLink = Converter.ToString(productsPageId), 4162 searchFeedId = productsPageId + "&feed=true", 4163 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 4164 searchPlaceholder = Translate("Search products"), 4165 searchTemplate = "SearchProductsTemplate", 4166 searchType = "product-search", 4167 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 4168 }; 4169 break; 4170 } 4171 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 4172 4173 if (type == "mini-search") { 4174 @RenderMiniSearch(searchConfiguration) 4175 } else { 4176 @RenderSearchBar(searchConfiguration) 4177 } 4178 } 4179 4180 @helper RenderSearchBar(SearchConfiguration options) 4181 { 4182 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar" 4183 data-page-size="7" 4184 data-search-feed-id="@options.searchFeedId" 4185 data-search-second-feed-id="@options.searchSecondFeedId" 4186 data-result-page-id="@options.resultPageLink" 4187 data-groups-page-id="@options.groupsFeedId" 4188 data-search-type="@options.searchType"> 4189 @if (options.showGroups) 4190 { 4191 <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> 4192 <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> 4193 } 4194 <div class="typeahead-search-field"> 4195 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 4196 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 4197 { 4198 <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> 4199 } 4200 else 4201 { 4202 <div class="dropdown dropdown--absolute-position dropdown--combined grid"> 4203 <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> 4204 <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> 4205 </div> 4206 } 4207 </div> 4208 <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> 4209 </div> 4210 } 4211 4212 @helper RenderMiniSearch(SearchConfiguration options) 4213 { 4214 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4215 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4216 4217 <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"> 4218 <div class="@menuLinkClass dw-mod" title="@Translate("Search")"> 4219 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 4220 </div> 4221 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod"> 4222 <div class="typeahead js-typeahead" id="ProductSearchBar" 4223 data-page-size="7" 4224 data-search-feed-id="@options.searchFeedId" 4225 data-search-second-feed-id="@options.searchSecondFeedId" 4226 data-result-page-id="@options.resultPageLink" 4227 data-search-type="@options.searchType"> 4228 <div class="typeahead-search-field"> 4229 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 4230 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 4231 { 4232 <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> 4233 } 4234 else 4235 { 4236 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned"> 4237 <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> 4238 <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> 4239 </div> 4240 } 4241 </div> 4242 </div> 4243 </div> 4244 </li> 4245 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4246 4247 @using System 4248 @using System.Web 4249 @using Dynamicweb.Rapido.Blocks.Extensibility 4250 @using Dynamicweb.Rapido.Blocks 4251 4252 @{ 4253 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4254 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 4255 4256 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master"); 4257 4258 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo"); 4259 headerConfigurationPage.RemoveBlock(configDesktopLogo); 4260 4261 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu"); 4262 headerConfigurationPage.RemoveBlock(configDesktopMenu); 4263 4264 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar"); 4265 headerConfigurationPage.RemoveBlock(configSearchBar); 4266 4267 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch"); 4268 headerConfigurationPage.RemoveBlock(configSearchAction); 4269 4270 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu"); 4271 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu); 4272 4273 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra"); 4274 4275 switch (headerConfigurationTopLayout) 4276 { 4277 case "condensed": //2 4278 configDesktopLogo.Design.Size = "auto-width"; 4279 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 4280 4281 configDesktopMenu.SortId = 20; 4282 configDesktopMenu.Design.Size = "auto"; 4283 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4284 4285 configDesktopActionsMenu.SortId = 30; 4286 configDesktopActionsMenu.Design.Size = "auto-width"; 4287 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4288 4289 if (!headerConfigurationHideSearch) 4290 { 4291 configSearchBar.SortId = 40; 4292 configSearchBar.Design.Size = "12"; 4293 configDesktopExtra.SortId = 50; 4294 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 4295 } 4296 break; 4297 case "splitted": //3 4298 configDesktopLogo.Design.Size = "auto"; 4299 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 4300 4301 if (!headerConfigurationHideSearch) 4302 { 4303 configSearchBar.SortId = 20; 4304 configSearchBar.Design.Size = "auto"; 4305 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 4306 } 4307 4308 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4309 4310 configDesktopActionsMenu.SortId = 20; 4311 configDesktopActionsMenu.Design.Size = "auto-width"; 4312 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4313 break; 4314 case "splitted-center": //4 4315 configDesktopLogo.Design.Size = "auto"; 4316 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 4317 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4318 4319 configDesktopActionsMenu.SortId = 30; 4320 configDesktopActionsMenu.Design.Size = "auto-width"; 4321 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 4322 4323 if (!headerConfigurationHideSearch) 4324 { 4325 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4326 } 4327 break; 4328 case "minimal": //5 4329 configDesktopLogo.Design.Size = "auto-width"; 4330 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 4331 4332 configDesktopMenu.Design.Size = "auto"; 4333 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4334 4335 configDesktopActionsMenu.SortId = 20; 4336 configDesktopActionsMenu.Design.Size = "auto-width"; 4337 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4338 4339 if (!headerConfigurationHideSearch) 4340 { 4341 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4342 } 4343 break; 4344 case "minimal-center": //6 4345 configDesktopLogo.Design.Size = "auto-width"; 4346 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 4347 4348 configDesktopMenu.Design.Size = "auto"; 4349 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4350 4351 configDesktopActionsMenu.SortId = 20; 4352 configDesktopActionsMenu.Design.Size = "auto-width"; 4353 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4354 4355 if (!headerConfigurationHideSearch) 4356 { 4357 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4358 } 4359 break; 4360 case "minimal-right": //7 4361 configDesktopLogo.Design.Size = "auto-width"; 4362 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 4363 4364 configDesktopMenu.Design.Size = "auto"; 4365 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4366 4367 configDesktopActionsMenu.SortId = 20; 4368 configDesktopActionsMenu.Design.Size = "auto-width"; 4369 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4370 4371 if (!headerConfigurationHideSearch) 4372 { 4373 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4374 } 4375 break; 4376 case "two-lines": //8 4377 configDesktopLogo.Design.Size = "auto"; 4378 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 4379 4380 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4381 4382 configDesktopActionsMenu.SortId = 20; 4383 configDesktopActionsMenu.Design.Size = "auto-width"; 4384 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4385 4386 if (!headerConfigurationHideSearch) 4387 { 4388 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4389 } 4390 break; 4391 case "two-lines-centered": //9 4392 configDesktopLogo.Design.Size = "auto"; 4393 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 4394 4395 configDesktopMenu.Design.Size = "auto-width"; 4396 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4397 4398 configDesktopActionsMenu.SortId = 20; 4399 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 4400 4401 if (!headerConfigurationHideSearch) 4402 { 4403 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 4404 } 4405 break; 4406 case "normal": //1 4407 default: 4408 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 4409 4410 if (!headerConfigurationHideSearch) 4411 { 4412 configSearchBar.SortId = 20; 4413 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 4414 } 4415 4416 configDesktopActionsMenu.SortId = 30; 4417 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 4418 4419 configDesktopActionsMenu.Design.Size = "auto-width"; 4420 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 4421 break; 4422 } 4423 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4424 4425 @using System 4426 @using System.Web 4427 @using Dynamicweb.Rapido.Blocks.Extensibility 4428 @using Dynamicweb.Rapido.Blocks 4429 4430 @{ 4431 4432 } @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"); var contactustext = Translate("Contact us"); if (!string.IsNullOrEmpty(toolsText)) { @*<div class="u-margin-top u-margin-bottom">@toolsText</div>*@ <div class="u-margin-top u-margin-bottom">@contactustext : <a href="tel:+4544916700">+45 44 91 67 00</a> | <a href="mailto:mega@megatrade.dk">mega@megatrade.dk</a></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> 4433 4434 @using System 4435 @using System.Web 4436 @using Dynamicweb.Rapido.Blocks.Extensibility 4437 @using Dynamicweb.Rapido.Blocks 4438 @using Dynamicweb.Rapido.Blocks.Components.General 4439 @using Dynamicweb.Frontend 4440 4441 @functions { 4442 int impersonationPageId; 4443 string impersonationLayout; 4444 int impersonationFeed; 4445 Block impersonationBar; 4446 4447 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName) 4448 { 4449 string username = ""; 4450 4451 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName)) 4452 { 4453 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName; 4454 } 4455 else if (!string.IsNullOrEmpty(name)) 4456 { 4457 username = name; 4458 } 4459 else if (!string.IsNullOrEmpty(email)) 4460 { 4461 username = email; 4462 } 4463 else 4464 { 4465 username = userName; 4466 } 4467 return username; 4468 } 4469 4470 string getUserName(UserViewModel user) 4471 { 4472 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 4473 } 4474 4475 string getUserName(Dynamicweb.Security.UserManagement.User user) 4476 { 4477 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 4478 } 4479 } 4480 4481 @{ 4482 impersonationPageId = GetPageIdByNavigationTag("Impersonation"); 4483 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar"; 4484 impersonationFeed = GetPageIdByNavigationTag("UsersFeed"); 4485 4486 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0) 4487 { 4488 impersonationBar = new Block 4489 { 4490 Id = "ImpersonationBar", 4491 SortId = 50, 4492 Template = RenderImpersonation(), 4493 SkipRenderBlocksList = true, 4494 Design = new Design 4495 { 4496 Size = "auto-width", 4497 HidePadding = true, 4498 RenderType = RenderType.Column 4499 } 4500 }; 4501 4502 if (impersonationLayout == "top-bar") { 4503 impersonationBar.SortId = 9; 4504 } 4505 4506 Block impersonationContent = new Block 4507 { 4508 Id = "ImpersonationContent", 4509 SortId = 20 4510 }; 4511 4512 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 4513 { 4514 //Render stop impersonation view 4515 impersonationContent.Template = RenderStopImpersonationView(); 4516 4517 4518 Modal stopImpersonation = new Modal 4519 { 4520 Id = "StopImpersonation", 4521 Heading = new Heading { 4522 Level = 2, 4523 Title = Translate("Sign out"), 4524 Icon = new Icon { 4525 Name = "fa-sign-out", 4526 Prefix = "fas", 4527 LabelPosition = IconLabelPosition.After 4528 } 4529 }, 4530 Width = ModalWidth.Sm, 4531 BodyTemplate = RenderStopImpersonationForm() 4532 }; 4533 4534 Block stopImpersonationBlock = new Block 4535 { 4536 Id = "StopImpersonationBlock", 4537 SortId = 10, 4538 Component = stopImpersonation 4539 }; 4540 impersonationBar.BlocksList.Add(stopImpersonationBlock); 4541 } 4542 else 4543 { 4544 //Render main view 4545 switch (impersonationLayout) 4546 { 4547 case "right-lower-box": 4548 impersonationContent.BlocksList.Add( 4549 new Block { 4550 Id = "RightLowerBoxHeader", 4551 SortId = 10, 4552 Component = new Heading { 4553 Level = 5, 4554 Title = Translate("View the list of users you can sign in as"), 4555 CssClass = "impersonation-text" 4556 } 4557 } 4558 ); 4559 impersonationContent.BlocksList.Add( 4560 new Block { 4561 Id = "RightLowerBoxContent", 4562 SortId = 20, 4563 Template = RenderImpersonationControls() 4564 } 4565 ); 4566 break; 4567 case "right-lower-bar": 4568 impersonationContent.BlocksList.Add( 4569 new Block { 4570 Id = "RightLowerBarContent", 4571 SortId = 10, 4572 Template = RenderImpersonationControls() 4573 } 4574 ); 4575 break; 4576 case "bar": 4577 default: 4578 impersonationContent.BlocksList.Add( 4579 new Block { 4580 Id = "ViewListLink", 4581 SortId = 20, 4582 Template = RenderViewListLink() 4583 } 4584 ); 4585 impersonationContent.BlocksList.Add( 4586 new Block { 4587 Id = "BarTypeaheadSearch", 4588 SortId = 30, 4589 Template = RenderTypeaheadSearch() 4590 } 4591 ); 4592 break; 4593 } 4594 } 4595 impersonationBar.BlocksList.Add(impersonationContent); 4596 4597 impersonationBar.BlocksList.Add( 4598 new Block 4599 { 4600 Id = "ImpersonationSearchTemplates", 4601 SortId = 30, 4602 Template = RenderSearchResultTemplate() 4603 } 4604 ); 4605 if (impersonationLayout != "bar" && impersonationLayout != "top-bar") 4606 { 4607 impersonationBar.BlocksList.Add( 4608 new Block 4609 { 4610 Id = "ImpersonationSearchScripts", 4611 SortId = 40, 4612 Template = RenderSearchScripts() 4613 } 4614 ); 4615 } 4616 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar); 4617 } 4618 } 4619 4620 @helper RenderImpersonation() 4621 { 4622 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList(); 4623 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" /> 4624 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation"> 4625 @if (impersonationLayout == "right-lower-box") 4626 { 4627 @RenderRightLowerBoxHeader() 4628 } 4629 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod"> 4630 @*Impersonation*@ 4631 @RenderBlockList(subBlocks) 4632 </div> 4633 </div> 4634 } 4635 4636 @helper RenderRightLowerBoxHeader() 4637 { 4638 <div class="impersonation__header dw-mod"> 4639 <div class="impersonation__title">@Translate("Impersonation")</div> 4640 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();"> 4641 @Render(new Icon 4642 { 4643 Prefix = "fas", 4644 Name = "fa-window-minimize" 4645 }) 4646 </label> 4647 </div> 4648 } 4649 4650 @helper RenderStopImpersonationView() 4651 { 4652 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 4653 string userName = getUserName(Pageview.User); 4654 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> "; 4655 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; 4656 4657 if (impersonationLayout == "right-lower-box") 4658 { 4659 <div class="u-margin-bottom--lg u-ta-center"> 4660 @impersonationText 4661 </div> 4662 <div class="u-margin-bottom--lg u-ta-center"> 4663 @RenderSwitchAccountButton() 4664 </div> 4665 @RenderStopImpersonationButton() 4666 } 4667 else 4668 { 4669 <div class="grid grid--align-center impersonation__stop-wrap"> 4670 <div class="impersonation-bar-item dw-mod"> 4671 @impersonationText 4672 </div> 4673 <div class="impersonation-bar-item dw-mod"> 4674 @RenderSwitchAccountButton() 4675 </div> 4676 <div class="impersonation-bar-item dw-mod"> 4677 @RenderStopImpersonationButton() 4678 </div> 4679 </div> 4680 } 4681 } 4682 4683 @helper RenderSwitchAccountButton() { 4684 @Render(new Button 4685 { 4686 Href = "/Default.aspx?ID=" + impersonationPageId, 4687 ButtonType = ButtonType.Button, 4688 ButtonLayout = ButtonLayout.Clean, 4689 Title = Translate("Switch account"), 4690 Icon = new Icon { 4691 Name = "fa-users", 4692 Prefix = "fal", 4693 LabelPosition = IconLabelPosition.After 4694 }, 4695 CssClass = "u-no-margin u-color-inherit" 4696 }) 4697 } 4698 4699 @helper RenderStopImpersonationForm() 4700 { 4701 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 4702 string userName = getUserName(Pageview.User); 4703 int pageId = Model.TopPage.ID; 4704 4705 <form method="post" class="u-no-margin"> 4706 @Render(new Button 4707 { 4708 ButtonType = ButtonType.Submit, 4709 ButtonLayout = ButtonLayout.Secondary, 4710 Title = Translate("Sign out as") + " " + userName, 4711 Href = "/Default.aspx?ID=" + impersonationPageId, 4712 CssClass = "btn--full", 4713 Name = "DwExtranetRemoveSecondaryUser" 4714 }) 4715 4716 @Render(new Button 4717 { 4718 ButtonType = ButtonType.Submit, 4719 ButtonLayout = ButtonLayout.Secondary, 4720 Title = Translate("Sign out as") + " " + secondaryUserName, 4721 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, 4722 CssClass = "btn--full", 4723 Name = "DwExtranetRemoveSecondaryUser" 4724 }) 4725 </form> 4726 } 4727 4728 @helper RenderStopImpersonationButton() { 4729 @Render(new Button 4730 { 4731 ButtonType = ButtonType.Button, 4732 ButtonLayout = ButtonLayout.Clean, 4733 Title = Translate("Sign out"), 4734 Icon = new Icon { 4735 Name = "fa-sign-out", 4736 Prefix = "fal", 4737 LabelPosition = IconLabelPosition.After 4738 }, 4739 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true", 4740 CssClass = "u-no-margin" 4741 }) 4742 } 4743 4744 @helper RenderImpersonationControls() 4745 { 4746 <div class="impersonation__controls"> 4747 @RenderViewListLink() 4748 @RenderSearchBox() 4749 </div> 4750 @RenderResultsList() 4751 } 4752 4753 @helper RenderViewListLink() 4754 { 4755 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as"); 4756 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link"; 4757 4758 @Render(new Link { 4759 ButtonLayout = ButtonLayout.None, 4760 Title = title, 4761 Href = "/Default.aspx?ID=" + impersonationPageId, 4762 CssClass = buttonClasses 4763 }) 4764 } 4765 4766 @helper RenderSearchBox() 4767 { 4768 <div class="impersonation__search-wrap"> 4769 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField"> 4770 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)"> 4771 <i class="fal fa-search"></i> 4772 </div> 4773 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();"> 4774 <i class="fal fa-times"></i> 4775 </div> 4776 </div> 4777 } 4778 4779 @helper RenderTypeaheadSearch() 4780 { 4781 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar" 4782 data-page-size="5" 4783 data-search-feed-id="@impersonationFeed" 4784 data-result-page-id="@impersonationPageId" 4785 data-search-type="user-search" 4786 data-search-parameter-name="q"> 4787 4788 <div class="typeahead-search-field"> 4789 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")"> 4790 <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> 4791 </div> 4792 </div> 4793 } 4794 4795 @helper RenderResultsList() 4796 { 4797 <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> 4798 } 4799 4800 @helper RenderSearchResultTemplate() 4801 { 4802 <script id="ImpersonationSearchResult" type="text/x-template"> 4803 {{#.}} 4804 {{#Users}} 4805 <li class="impersonation__search-results-item impersonation-user"> 4806 <form method="post" class="impersonation-user__form" name="account{{id}}"> 4807 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}"> 4808 <div class="impersonation-user__info"> 4809 <div class="impersonation-user__name">{{userName}}</div> 4810 <div class="impersonation-user__number">{{customerNumber}}</div> 4811 </div> 4812 @Render(new Button 4813 { 4814 ButtonType = ButtonType.Submit, 4815 ButtonLayout = ButtonLayout.Secondary, 4816 Title = Translate("Sign in as"), 4817 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "") 4818 }) 4819 </form> 4820 </li> 4821 {{/Users}} 4822 {{#unless Users}} 4823 <li class="impersonation__search-results-item impersonation__search-results-item--not-found"> 4824 @Translate("Your search gave 0 results") 4825 </li> 4826 {{/unless}} 4827 {{/.}} 4828 </script> 4829 } 4830 4831 @helper RenderSearchScripts() 4832 { 4833 <script> 4834 let inputDelayTimer; 4835 function searchKeyUpHandler(e) { 4836 clearTimeout(inputDelayTimer); 4837 let value = e.target.value; 4838 if (value != "") { 4839 inputDelayTimer = setTimeout(function () { 4840 updateResults(value); 4841 }, 500); 4842 } else { 4843 clearResults(); 4844 } 4845 }; 4846 4847 function updateResults(value) { 4848 if (value == "") { 4849 return null; 4850 } 4851 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value); 4852 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden"); 4853 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden"); 4854 } 4855 4856 function clearResults() { 4857 document.getElementById("ImpersonationBoxSearchField").value = ""; 4858 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults"); 4859 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden"); 4860 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden"); 4861 } 4862 </script> 4863 } @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"> <div class="" style="display:flex; flex-wrap:wrap;align-items: baseline;"> {{shippingmethod}} {{#ifCond shippingmethod "===" "Gebyr"}} <div class="help-tip dw-mod"> <p>@Translate("Custom fee help text")</p> </div> {{/ifCond}} </div> </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> 4864 4865 @using Dynamicweb.Rapido.Blocks.Extensibility 4866 @using Dynamicweb.Rapido.Blocks 4867 @using Dynamicweb.Rapido.Blocks.Components.General 4868 @using Dynamicweb.Rapido.Blocks.Components 4869 @using Dynamicweb.Rapido.Services 4870 4871 @{ 4872 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : ""; 4873 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 4874 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 4875 4876 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType)) 4877 { 4878 if (addToCartNotificationType == "modal") 4879 { 4880 Block addToCartNotificationModal = new Block 4881 { 4882 Id = "AddToCartNotificationModal", 4883 Template = RenderAddToCartNotificationModal() 4884 }; 4885 4886 Block addToCartNotificationScript = new Block 4887 { 4888 Id = "AddToCartNotificationScript", 4889 Template = RenderAddToCartNotificationModalScript() 4890 }; 4891 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal); 4892 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 4893 } 4894 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 4895 { 4896 Block addToCartNotificationScript = new Block 4897 { 4898 Id = "AddToCartNotificationScript", 4899 Template = RenderAddToCartNotificationToggleScript() 4900 }; 4901 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 4902 } 4903 } 4904 } 4905 4906 @helper RenderAddToCartNotificationModal() 4907 { 4908 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div> 4909 } 4910 4911 @helper RenderAddToCartNotificationModalScript() 4912 { 4913 int cartPageId = GetPageIdByNavigationTag("CartPage"); 4914 4915 <script id="LastAddedProductTemplate" type="text/x-template"> 4916 @{ 4917 4918 Modal lastAddedProduct = new Modal 4919 { 4920 Id = "LastAddedProduct", 4921 Heading = new Heading 4922 { 4923 Level = 2, 4924 Title = Translate("Product is added to the cart") 4925 }, 4926 Width = ModalWidth.Md, 4927 BodyTemplate = RenderModalContent() 4928 }; 4929 4930 lastAddedProduct.AddActions( 4931 new Button 4932 { 4933 ButtonType = ButtonType.Button, 4934 ButtonLayout = ButtonLayout.Secondary, 4935 Title = Translate("Continue shopping"), 4936 CssClass = "u-pull--left u-no-margin btn--sm", 4937 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 4938 }, 4939 new Link 4940 { 4941 Href = "/Default.aspx?ID=" + cartPageId, 4942 ButtonLayout = ButtonLayout.Secondary, 4943 CssClass = "u-pull--right u-no-margin btn--sm", 4944 Title = Translate("Proceed to checkout"), 4945 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 4946 } 4947 ); 4948 4949 @Render(lastAddedProduct) 4950 } 4951 </script> 4952 <script> 4953 document.addEventListener('addToCart', function (event) { 4954 Cart.ShowLastAddedProductModal(event.detail); 4955 }); 4956 </script> 4957 } 4958 4959 @helper RenderModalContent() 4960 { 4961 <div class="grid"> 4962 <div class="grid__col-2"> 4963 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true }) 4964 </div> 4965 <div class="u-padding grid--align-self-center"> 4966 <span>{{quantity}}</span> x 4967 </div> 4968 <div class="grid__col-auto grid--align-self-center"> 4969 <div>{{productInfo.name}}</div> 4970 {{#if productInfo.variantName}} 4971 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small> 4972 {{/if}} 4973 {{#if productInfo.unitName}} 4974 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small> 4975 {{/if}} 4976 </div> 4977 </div> 4978 } 4979 4980 @helper RenderAddToCartNotificationToggleScript() 4981 { 4982 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 4983 4984 <script> 4985 document.addEventListener('addToCart', function () { 4986 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId'); 4987 }); 4988 </script> 4989 } @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4990 4991 @using System 4992 @using System.Web 4993 @using System.Collections.Generic 4994 @using Dynamicweb.Rapido.Blocks.Extensibility 4995 @using Dynamicweb.Rapido.Blocks 4996 @using Dynamicweb.Rapido.Blocks.Components.General 4997 4998 @functions { 4999 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master"); 5000 } 5001 5002 @{ 5003 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content"); 5004 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content"); 5005 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content"); 5006 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header"); 5007 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header"); 5008 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header"); 5009 5010 Block masterFooterContent = new Block() 5011 { 5012 Id = "MasterFooterContent", 5013 SortId = 10, 5014 Template = RenderFooter(), 5015 SkipRenderBlocksList = true 5016 }; 5017 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent); 5018 5019 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader)) 5020 { 5021 Block masterFooterColumnOne = new Block 5022 { 5023 Id = "MasterFooterColumnOne", 5024 SortId = 10, 5025 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent), 5026 Design = new Design 5027 { 5028 Size = "auto", 5029 RenderType = RenderType.Column 5030 } 5031 }; 5032 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne); 5033 } 5034 5035 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader)) 5036 { 5037 Block masterFooterColumnTwo = new Block 5038 { 5039 Id = "MasterFooterColumnTwo", 5040 SortId = 20, 5041 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent), 5042 Design = new Design 5043 { 5044 Size = "auto", 5045 RenderType = RenderType.Column 5046 } 5047 }; 5048 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo); 5049 } 5050 5051 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader)) 5052 { 5053 Block masterFooterColumnThree = new Block 5054 { 5055 Id = "MasterFooterColumnThree", 5056 SortId = 30, 5057 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent), 5058 Design = new Design 5059 { 5060 Size = "auto", 5061 RenderType = RenderType.Column 5062 } 5063 }; 5064 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree); 5065 } 5066 5067 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp")) 5068 { 5069 Block masterFooterNewsletterSignUp = new Block 5070 { 5071 Id = "MasterFooterNewsletterSignUp", 5072 SortId = 40, 5073 Template = RenderFooterNewsletterSignUp(), 5074 Design = new Design 5075 { 5076 Size = "auto", 5077 RenderType = RenderType.Column 5078 } 5079 }; 5080 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp); 5081 } 5082 5083 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0) 5084 { 5085 Block masterFooterSocialLinks = new Block 5086 { 5087 Id = "MasterFooterSocialLinks", 5088 SortId = 50, 5089 Template = RenderFooterSocialLinks(), 5090 Design = new Design 5091 { 5092 Size = "auto", 5093 RenderType = RenderType.Column 5094 } 5095 }; 5096 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks); 5097 } 5098 5099 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0) 5100 { 5101 Block masterFooterPayments = new Block 5102 { 5103 Id = "MasterFooterPayments", 5104 SortId = 60, 5105 Template = RenderFooterPayments(), 5106 Design = new Design 5107 { 5108 Size = "12", 5109 RenderType = RenderType.Column 5110 } 5111 }; 5112 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments); 5113 } 5114 5115 Block masterFooterCopyright = new Block 5116 { 5117 Id = "MasterFooterCopyright", 5118 SortId = 70, 5119 Template = RenderFooterCopyright(), 5120 Design = new Design 5121 { 5122 Size = "12", 5123 RenderType = RenderType.Column 5124 } 5125 }; 5126 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright); 5127 } 5128 5129 @helper RenderFooter() 5130 { 5131 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList(); 5132 5133 <footer class="footer no-print dw-mod"> 5134 <div class="center-container top-container__center-container dw-mod"> 5135 <div class="grid grid--external-bleed-x"> 5136 @RenderBlockList(subBlocks) 5137 </div> 5138 </div> 5139 </footer> 5140 } 5141 5142 @helper RenderFooterColumn(string header, string content) 5143 { 5144 <h3 class="footer__heading dw-mod">@header</h3> 5145 <div class="footer__content dw-mod"> 5146 @content 5147 </div> 5148 } 5149 5150 @helper RenderFooterNewsletterSignUp() 5151 { 5152 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString(); 5153 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart }; 5154 5155 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId }); 5156 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" }); 5157 form.Add(new TextField { 5158 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"), 5159 Type = TextFieldType.Email, 5160 ActionButton = new Button { 5161 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed" 5162 } 5163 }); 5164 5165 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3> 5166 <div class="footer__content dw-mod"> 5167 @Render(form) 5168 </div> 5169 } 5170 5171 @helper RenderFooterSocialLinks() 5172 { 5173 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3> 5174 <div class="footer__content dw-mod"> 5175 <div class="collection dw-mod"> 5176 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks")) 5177 { 5178 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 5179 string socialIconClass = socialIcon.SelectedValue; 5180 string socialIconTitle = socialIcon.SelectedName; 5181 string socialLink = socialitem.GetString("Link"); 5182 5183 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a> 5184 } 5185 </div> 5186 </div> 5187 } 5188 5189 @helper RenderFooterPayments() 5190 { 5191 <div class="footer__content dw-mod"> 5192 <div class="collection dw-mod"> 5193 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments")) 5194 { 5195 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel; 5196 string paymentImage = null; 5197 string paymentTitle = paymentItem.SelectedName; 5198 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault(); 5199 if (selected != null) 5200 { 5201 paymentImage = selected.Icon; 5202 } 5203 5204 <div class="footer__card-type"> 5205 <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" /> 5206 </div> 5207 } 5208 </div> 5209 </div> 5210 } 5211 5212 @helper RenderFooterCopyright() 5213 { 5214 <div class="grid__col-12 footer__copyright dw-mod"> 5215 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p> 5216 </div> 5217 } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5218 5219 @using System 5220 @using System.Web 5221 @using System.Collections.Generic 5222 @using Dynamicweb.Rapido.Blocks.Extensibility 5223 @using Dynamicweb.Rapido.Blocks 5224 @using Dynamicweb.Ecommerce.Common 5225 5226 @{ 5227 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master"); 5228 5229 Block masterScriptReferences = new Block() 5230 { 5231 Id = "MasterScriptReferences", 5232 SortId = 1, 5233 Template = RenderMasterScriptReferences() 5234 }; 5235 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences); 5236 } 5237 5238 @helper RenderMasterScriptReferences() { 5239 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script> 5240 <script src="/Files/Templates/Designs/Rapido/js/master.min.js"></script> 5241 5242 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript")) 5243 { 5244 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js"></script> 5245 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js"); 5246 } 5247 5248 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"); 5249 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js"); 5250 } @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 5251 @using Dynamicweb.Rapido.Blocks.Components.General 5252 @using Dynamicweb.Rapido.Blocks 5253 @using System.IO 5254 5255 5256 @using Dynamicweb.Rapido.Blocks.Components.General 5257 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5258 5259 5260 @* Component *@ 5261 5262 @helper RenderVariantMatrix(VariantMatrix settings) { 5263 if (settings != null) 5264 { 5265 int productLoopCounter = 0; 5266 int groupCount = 0; 5267 List<VariantOption> firstDimension = new List<VariantOption>(); 5268 List<VariantOption> secondDimension = new List<VariantOption>(); 5269 List<VariantOption> thirdDimension = new List<VariantOption>(); 5270 5271 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 5272 { 5273 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 5274 { 5275 if (groupCount == 0) { 5276 firstDimension.Add(variantOptions); 5277 } 5278 if (groupCount == 1) 5279 { 5280 secondDimension.Add(variantOptions); 5281 } 5282 if (groupCount == 2) 5283 { 5284 thirdDimension.Add(variantOptions); 5285 } 5286 } 5287 groupCount++; 5288 } 5289 5290 int rowCount = 0; 5291 int columnCount = 0; 5292 5293 <script> 5294 var variantsCollection = []; 5295 </script> 5296 5297 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 5298 @if (groupCount == 1) 5299 { 5300 <tbody> 5301 @foreach (VariantOption firstVariantOption in firstDimension) 5302 { 5303 var variantId = firstVariantOption.Id; 5304 <tr> 5305 <td class="u-bold"> 5306 @firstVariantOption.Name 5307 </td> 5308 <td> 5309 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 5310 </td> 5311 </tr> 5312 productLoopCounter++; 5313 } 5314 5315 <tr> 5316 <td>&nbsp;</td> 5317 <td> 5318 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 5319 </td> 5320 </tr> 5321 </tbody> 5322 } 5323 @if (groupCount == 2) 5324 { 5325 <thead> 5326 <tr> 5327 <td>&nbsp;</td> 5328 @foreach (VariantOption variant in secondDimension) 5329 { 5330 <td>@variant.Name</td> 5331 } 5332 </tr> 5333 </thead> 5334 <tbody> 5335 @foreach (VariantOption firstVariantOption in firstDimension) 5336 { 5337 string variantId = ""; 5338 columnCount = 0; 5339 5340 <tr> 5341 <td class="u-min-w120px">@firstVariantOption.Name</td> 5342 5343 @foreach (VariantOption secondVariantOption in secondDimension) 5344 { 5345 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 5346 <td> 5347 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 5348 </td> 5349 5350 columnCount++; 5351 5352 productLoopCounter++; 5353 } 5354 5355 <td> 5356 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 5357 </td> 5358 </tr> 5359 5360 rowCount++; 5361 } 5362 5363 @{ 5364 columnCount = 0; 5365 } 5366 5367 <tr> 5368 <td>&nbsp;</td> 5369 @foreach (VariantOption secondVariantOption in secondDimension) 5370 { 5371 <td> 5372 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 5373 </td> 5374 5375 columnCount++; 5376 } 5377 <td>&nbsp;</td> 5378 </tr> 5379 </tbody> 5380 } 5381 @if (groupCount == 3) 5382 { 5383 <thead> 5384 <tr> 5385 <td>&nbsp;</td> 5386 @foreach (VariantOption thirdVariantOption in thirdDimension) 5387 { 5388 <td>@thirdVariantOption.Name</td> 5389 } 5390 </tr> 5391 </thead> 5392 <tbody> 5393 @foreach (VariantOption firstVariantOption in firstDimension) 5394 { 5395 int colspan = (thirdDimension.Count + 1); 5396 5397 <tr> 5398 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 5399 </tr> 5400 5401 foreach (VariantOption secondVariantOption in secondDimension) 5402 { 5403 string variantId = ""; 5404 columnCount = 0; 5405 5406 <tr> 5407 <td class="u-min-w120px">@secondVariantOption.Name</td> 5408 5409 @foreach (VariantOption thirdVariantOption in thirdDimension) 5410 { 5411 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 5412 5413 <td> 5414 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 5415 </td> 5416 5417 columnCount++; 5418 productLoopCounter++; 5419 } 5420 5421 <td> 5422 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 5423 </td> 5424 </tr> 5425 rowCount++; 5426 } 5427 } 5428 5429 @{ 5430 columnCount = 0; 5431 } 5432 5433 <tr> 5434 <td>&nbsp;</td> 5435 @foreach (VariantOption thirdVariantOption in thirdDimension) 5436 { 5437 <td> 5438 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 5439 </td> 5440 5441 columnCount++; 5442 } 5443 <td>&nbsp;</td> 5444 </tr> 5445 </tbody> 5446 } 5447 </table> 5448 5449 <script> 5450 document.addEventListener("DOMContentLoaded", function (event) { 5451 MatrixUpdateQuantity("@settings.ProductId"); 5452 }); 5453 5454 MatrixUpdateQuantity = function (productId) { 5455 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 5456 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 5457 5458 var qtyRowArr = []; 5459 var qtyColumnArr = []; 5460 5461 var totalQty = 0; 5462 5463 for (var i = 0; i < allQtyFields.length; i++) { 5464 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 5465 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 5466 } 5467 5468 for (var i = 0; i < allQtyFields.length; i++) { 5469 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 5470 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 5471 totalQty += parseFloat(allQtyFields[i].value); 5472 } 5473 5474 //Update row counters 5475 for (var i = 0; i < qtyRowArr.length; i++) { 5476 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 5477 5478 if (qtyRowArr[i] != undefined && qtyCounter != null) { 5479 var currentCount = qtyCounter.innerHTML; 5480 qtyCounter.innerHTML = qtyRowArr[i]; 5481 5482 if (currentCount != qtyCounter.innerHTML) { 5483 qtyCounter.classList.add("qty-field--active"); 5484 } 5485 } 5486 5487 } 5488 5489 //Update column counters 5490 for (var i = 0; i < qtyColumnArr.length; i++) { 5491 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 5492 5493 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 5494 var currentCount = qtyCounter.innerHTML; 5495 qtyCounter.innerHTML = qtyColumnArr[i]; 5496 5497 if (currentCount != qtyCounter.innerHTML) { 5498 qtyCounter.classList.add("qty-field--active"); 5499 } 5500 } 5501 } 5502 5503 if (document.getElementById("TotalQtyCount_" + productId)) { 5504 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 5505 } 5506 5507 //Clean up animations 5508 setTimeout(function () { 5509 for (var i = 0; i < qtyRowArr.length; i++) { 5510 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 5511 if (qtyCounter != null) { 5512 qtyCounter.classList.remove("qty-field--active"); 5513 } 5514 } 5515 for (var i = 0; i < qtyColumnArr.length; i++) { 5516 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 5517 if (qtyCounter != null) { 5518 qtyCounter.classList.remove("qty-field--active"); 5519 } 5520 } 5521 }, 1000); 5522 } 5523 </script> 5524 } 5525 } 5526 5527 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 5528 { 5529 string loopCount = productLoopCounter.ToString(); 5530 5531 bool combinationFound = false; 5532 double stock = 0; 5533 double quantityValue = 0; 5534 string note = ""; 5535 5536 VariantProduct variantProduct = null; 5537 5538 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 5539 { 5540 stock = variantProduct.Stock; 5541 quantityValue = variantProduct.Quantity; 5542 combinationFound = true; 5543 } 5544 5545 if (combinationFound) 5546 { 5547 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 5548 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 5549 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 5550 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 5551 <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"> 5552 5553 if (stock != 0) 5554 { 5555 <small>@Translate("Stock") @stock</small> 5556 } 5557 5558 <script> 5559 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 5560 variantsCollection.push(variants); 5561 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 5562 </script> 5563 } 5564 else 5565 { 5566 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 5567 } 5568 } 5569 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5570 5571 @* Component *@ 5572 5573 @helper RenderAddToCart(AddToCart settings) 5574 { 5575 //set Id for quantity selector to get it's value from button 5576 if (settings.QuantitySelector != null) 5577 { 5578 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 5579 { 5580 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 5581 } 5582 5583 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 5584 5585 if (settings.Disabled) 5586 { 5587 settings.QuantitySelector.Disabled = true; 5588 } 5589 5590 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 5591 { 5592 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 5593 } 5594 } 5595 5596 if (settings.Disabled) 5597 { 5598 settings.AddButton.Disabled = true; 5599 } 5600 5601 settings.AddButton.CssClass += " btn--condensed"; 5602 5603 //unitsSelector 5604 if (settings.UnitSelector != null) 5605 { 5606 if (settings.Disabled) 5607 { 5608 settings.QuantitySelector.Disabled = true; 5609 } 5610 } 5611 5612 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 5613 @if (settings.UnitSelector != null) 5614 { 5615 @Render(settings.UnitSelector) 5616 } 5617 @if (settings.QuantitySelector != null) 5618 { 5619 @Render(settings.QuantitySelector) 5620 } 5621 @Render(settings.AddButton) 5622 </div> 5623 } 5624 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5625 5626 @* Component *@ 5627 5628 @helper RenderAddToCartButton(AddToCartButton settings) 5629 { 5630 if (!settings.HideTitle) 5631 { 5632 if (string.IsNullOrEmpty(settings.Title)) 5633 { 5634 if (settings.BuyForPoints) 5635 { 5636 settings.Title = Translate("Buy with points"); 5637 } 5638 else 5639 { 5640 settings.Title = Translate("Add to cart"); 5641 } 5642 } 5643 } 5644 else 5645 { 5646 settings.Title = ""; 5647 } 5648 5649 if (settings.Icon == null) 5650 { 5651 settings.Icon = new Icon(); 5652 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 5653 } 5654 5655 if (string.IsNullOrEmpty(settings.Icon.Name)) 5656 { 5657 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 5658 } 5659 5660 settings.OnClick = "Cart.AddToCart(event, { " + 5661 "id: '" + settings.ProductId + "'," + 5662 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 5663 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 5664 (settings.BuyForPoints ? "buyForPoints: true," : "") + 5665 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 5666 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 5667 "});" + settings.OnClick; 5668 5669 @RenderButton(settings) 5670 } 5671 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5672 5673 @* Component *@ 5674 5675 @helper RenderUnitSelector(UnitSelector settings) 5676 { 5677 if (string.IsNullOrEmpty(settings.Id)) 5678 { 5679 settings.Id = Guid.NewGuid().ToString("N"); 5680 } 5681 var disabledClass = settings.Disabled ? "disabled" : ""; 5682 5683 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 5684 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 5685 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 5686 <div class="dropdown__content dw-mod"> 5687 @settings.OptionsContent 5688 </div> 5689 <label class="dropdown-trigger-off" for="@settings.Id"></label> 5690 </div> 5691 } 5692 @using System.Reflection 5693 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5694 5695 @* Component *@ 5696 5697 @helper RenderQuantitySelector(QuantitySelector settings) 5698 { 5699 var attributes = new Dictionary<string, string>(); 5700 5701 /*base settings*/ 5702 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 5703 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 5704 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 5705 if (settings.Disabled) { attributes.Add("disabled", "true"); } 5706 if (settings.Required) { attributes.Add("required", "true"); } 5707 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 5708 /*end*/ 5709 5710 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 5711 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 5712 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 5713 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 5714 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 5715 if (settings.Min == null) { settings.Min = 1; } 5716 attributes.Add("min", settings.Min.ToString()); 5717 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 5718 if (settings.Value == null) { settings.Value = 1; } 5719 attributes.Add("value", settings.Value.ToString()); 5720 attributes.Add("type", "number"); 5721 5722 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 5723 5724 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 5725 } 5726 @using Dynamicweb.Rapido.Blocks.Components 5727 5728 @using Dynamicweb.Frontend 5729 @using Dynamicweb.Frontend.Devices 5730 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 5731 @using Dynamicweb.Rapido.Blocks.Components.General 5732 @using System.Collections.Generic; 5733 5734 @* Component *@ 5735 5736 @helper RenderCustomerCenterList(CustomerCenterList settings) 5737 { 5738 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 5739 string hideActions = isTouchDevice ? "u-block" : ""; 5740 5741 <table class="table data-list dw-mod"> 5742 @if (settings.GetHeaders().Length > 0) { 5743 <thead> 5744 <tr class="u-bold"> 5745 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 5746 { 5747 var attributes = new Dictionary<string, string>(); 5748 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 5749 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 5750 attributes.Add("align", header.Align.ToString()); 5751 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 5752 5753 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 5754 } 5755 </tr> 5756 </thead> 5757 } 5758 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 5759 { 5760 int columnCount = 0; 5761 int totalColumns = listItem.GetInfoItems().Length; 5762 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : ""; 5763 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 5764 5765 var attributes = new Dictionary<string, string>(); 5766 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 5767 5768 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 5769 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 5770 <tr> 5771 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 5772 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 5773 5774 <td rowspan="2" @onClick class="data-list__main-item dw-mod"> 5775 @if (!string.IsNullOrEmpty(listItem.Title)) { 5776 <div class="u-bold">@listItem.Title</div> 5777 } 5778 @if (!string.IsNullOrEmpty(listItem.Description)) { 5779 <div>@listItem.Description</div> 5780 } 5781 </td> 5782 } 5783 5784 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 5785 { 5786 var infoAttributes = new Dictionary<string, string>(); 5787 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 5788 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 5789 infoAttributes.Add("align", infoItem.Align.ToString()); 5790 5791 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 5792 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 5793 5794 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 5795 @if (!string.IsNullOrEmpty(infoItem.Title)) { 5796 <div>@infoItem.Title</div> 5797 } 5798 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 5799 <div><small>@infoItem.Subtitle</small></div> 5800 } 5801 </td> 5802 5803 columnCount++; 5804 } 5805 </tr> 5806 <tr> 5807 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 5808 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 5809 @foreach (ButtonBase action in listItem.GetActions()) 5810 { 5811 action.ButtonLayout = ButtonLayout.LinkClean; 5812 action.Icon.CssClass += " u-full-height"; 5813 action.CssClass += " data-list__action-button link"; 5814 5815 @Render(action) 5816 } 5817 </div> 5818 </td> 5819 </tr> 5820 </tbody> 5821 } 5822 </table> 5823 } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5824 5825 @using System 5826 @using System.Web 5827 @using System.Collections.Generic 5828 @using Dynamicweb.Rapido.Blocks.Extensibility 5829 @using Dynamicweb.Rapido.Blocks 5830 5831 @{ 5832 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 5833 5834 Block primaryBottomSnippets = new Block() 5835 { 5836 Id = "MasterJavascriptInitializers", 5837 SortId = 100, 5838 Template = RenderPrimaryBottomSnippets() 5839 }; 5840 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets); 5841 5842 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 5843 { 5844 Block miniCartPageId = new Block 5845 { 5846 Id = "MiniCartPageId", 5847 Template = RenderMiniCartPageId() 5848 }; 5849 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId); 5850 } 5851 } 5852 5853 @helper RenderPrimaryBottomSnippets() 5854 { 5855 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode"); 5856 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 5857 5858 if (isWireframeMode) 5859 { 5860 <script> 5861 Wireframe.Init(true); 5862 </script> 5863 } 5864 5865 5866 if (useGoogleTagManager) 5867 { 5868 <script> 5869 document.addEventListener('addToCart', function(event) { 5870 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 5871 if (typeof googleImpression == "string") { 5872 googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 5873 } 5874 dataLayer.push({ 5875 'event': 'addToCart', 5876 'ecommerce': { 5877 'currencyCode': googleImpression.currency, 5878 'add': { 5879 'products': [{ 5880 'name': googleImpression.name, 5881 'id': googleImpression.id, 5882 'price': googleImpression.price, 5883 'brand': googleImpression.brand, 5884 'category': googleImpression.category, 5885 'variant': googleImpression.variant, 5886 'quantity': event.detail.quantity 5887 }] 5888 } 5889 } 5890 }); 5891 }); 5892 </script> 5893 } 5894 5895 //if digitalwarehouse 5896 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart")) 5897 { 5898 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]); 5899 5900 if (string.IsNullOrEmpty(cartContextId)) 5901 { 5902 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2"); 5903 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps); 5904 cartContextId = cartSettings.OrderContextID; 5905 HttpContext.Current.Application["DownloadCartContext"] = cartContextId; 5906 } 5907 5908 <script> 5909 let downloadCart = new DownloadCart({ 5910 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"), 5911 contextId: "@cartContextId", 5912 addButtonText: "@Translate("Add")", 5913 removeButtonText: "@Translate("Remove")" 5914 }); 5915 </script> 5916 } 5917 5918 <!--@Javascripts--> 5919 } 5920 5921 @helper RenderMiniCartPageId() 5922 { 5923 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5924 <script> 5925 window.cartId = "@miniCartFeedPageId"; 5926 </script> 5927 } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5928 5929 @using System 5930 @using System.Web 5931 @using System.Collections.Generic 5932 @using Dynamicweb.Rapido.Blocks 5933 5934 @{ 5935 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master"); 5936 5937 } @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> 5938 5939 5940 @using Dynamicweb.Extensibility 5941 @using Dynamicweb.Core 5942 @using Dynamicweb.Rapido.Blocks.Components 5943 @using Dynamicweb.Rapido.Blocks.Components.Articles 5944 @using Dynamicweb.Rapido.Blocks.Components.General 5945 @using Dynamicweb.Rapido.Blocks 5946 @using Dynamicweb.Content.Items 5947 5948 @functions { 5949 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle"); 5950 5951 public string GetParentSettingsItem(string systemName) { 5952 string item = null; 5953 5954 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID); 5955 while (current != null && current.Parent != current) { 5956 var temp = current.Item != null ? current.Item[systemName] : ""; 5957 5958 if (temp != null) { 5959 item = temp.ToString(); 5960 5961 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) { 5962 break; 5963 } 5964 } 5965 5966 current = current.Parent; 5967 } 5968 5969 return item; 5970 } 5971 5972 public string GetArticleCategory(int pageId) 5973 { 5974 string categoryName = null; 5975 5976 //Secure that the article is not in the root folder = Actual has a category 5977 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 5978 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 5979 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 5980 { 5981 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName(); 5982 } 5983 } 5984 } 5985 5986 return categoryName; 5987 } 5988 5989 public string GetArticleCategoryColor(int pageId) 5990 { 5991 string categoryColor = ""; 5992 5993 //Secure that the article is not in the root folder = Actual has a category 5994 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 5995 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 5996 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 5997 { 5998 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null) 5999 { 6000 var service = new ColorSwatchService(); 6001 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString(); 6002 6003 if (!categoryColor.Contains("#")) { 6004 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor); 6005 } 6006 } 6007 } 6008 } 6009 } 6010 6011 return categoryColor; 6012 } 6013 } 6014 6015 @{ 6016 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed")); 6017 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString(); 6018 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default"; 6019 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout; 6020 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default"; 6021 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout; 6022 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default"; 6023 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout; 6024 6025 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12"; 6026 string contentColumns = textLayout != "full" ? "8" : "12"; 6027 6028 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0; 6029 6030 ArticleHeaderLayout headerLayout; 6031 6032 switch (topLayout) 6033 { 6034 case "default": 6035 headerLayout = ArticleHeaderLayout.Clean; 6036 break; 6037 case "split": 6038 headerLayout = ArticleHeaderLayout.Split; 6039 break; 6040 case "banner": 6041 headerLayout = ArticleHeaderLayout.Banner; 6042 break; 6043 case "overlay": 6044 headerLayout = ArticleHeaderLayout.Overlay; 6045 break; 6046 default: 6047 headerLayout = ArticleHeaderLayout.Clean; 6048 break; 6049 } 6050 6051 6052 Block articleContainer = new Block 6053 { 6054 Id = "ArticleContainer", 6055 SortId = 10, 6056 Design = new Design 6057 { 6058 RenderType = RenderType.Row 6059 }, 6060 BlocksList = new List<Block> { 6061 new Block { 6062 Id = "ArticleBody", 6063 SortId = 30, 6064 Design = new Design { 6065 RenderType = RenderType.Column, 6066 Size = "12", 6067 HidePadding = true 6068 } 6069 } 6070 } 6071 }; 6072 articlePage.Add(articleContainer); 6073 6074 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary; 6075 6076 switch (Model.Item.GetString("ButtonDesign")) { 6077 case "primary": 6078 topBannerButtonLayout = ButtonLayout.Primary; 6079 break; 6080 case "secondary": 6081 topBannerButtonLayout = ButtonLayout.Secondary; 6082 break; 6083 case "teritary": 6084 topBannerButtonLayout = ButtonLayout.Tertiary; 6085 break; 6086 case "link": 6087 topBannerButtonLayout = ButtonLayout.Link; 6088 break; 6089 } 6090 6091 ArticleHeader topBanner = new ArticleHeader 6092 { 6093 Layout = headerLayout, 6094 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } }, 6095 Heading = Model.Item.GetString("Title"), 6096 Subheading = Model.Item.GetString("Summary"), 6097 TextColor = "#fff", 6098 Author = Model.Item.GetString("Author"), 6099 Date = Model.Item.GetString("Date"), 6100 Category = GetArticleCategory(Model.ID), 6101 CategoryColor = GetArticleCategoryColor(Model.ID), 6102 Link = Model.Item.GetString("Link"), 6103 LinkText = Model.Item.GetString("LinkText"), 6104 ButtonLayout = topBannerButtonLayout, 6105 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0, 6106 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0, 6107 ExternalParagraphId = externalParagraphId 6108 }; 6109 6110 Block articleTop = new Block 6111 { 6112 Id = "ArticleHead", 6113 SortId = 20, 6114 Component = topBanner, 6115 Design = new Design 6116 { 6117 RenderType = RenderType.Column, 6118 Size = "12", 6119 HidePadding = true, 6120 CssClass = "article-head" 6121 } 6122 }; 6123 articlePage.Add("ArticleContainer", articleTop); 6124 6125 6126 Block articleBodyRow = new Block 6127 { 6128 Id = "ArticleBodyRow", 6129 SortId = 10, 6130 SkipRenderBlocksList = true 6131 }; 6132 articlePage.Add("ArticleBody", articleBodyRow); 6133 6134 6135 if (Model.Item.GetString("Paragraphs") != null) 6136 { 6137 int count = 0; 6138 foreach (var paragraph in Model.Item.GetItems("Paragraphs")) 6139 { 6140 if (!paragraph.GetBoolean("RenderAsQuote")) 6141 { 6142 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default"; 6143 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap; 6144 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 6145 6146 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>") 6147 { 6148 string firstLetter = paragraph.GetString("Text").Substring(3, 1); 6149 text = paragraph.GetString("Text").Remove(3, 1); 6150 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>"); 6151 } 6152 6153 if (paragraph.GetFile("Image") != null) 6154 { 6155 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : ""; 6156 6157 Block articleParagraphImage = new Block 6158 { 6159 Id = "ArticleParagraph" + count + "Image", 6160 SortId = (count * 10), 6161 Design = new Design 6162 { 6163 RenderType = RenderType.Column, 6164 Size = imageColumns, 6165 CssClass = "u-color-light--bg u-padding--lg" 6166 } 6167 }; 6168 6169 if (imageLayout == "banner") 6170 { 6171 ArticleBanner banner = new ArticleBanner 6172 { 6173 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") }, 6174 Heading = imageTitle, 6175 UseFilters = false 6176 }; 6177 articleParagraphImage.Component = banner; 6178 } 6179 else 6180 { 6181 ArticleImage image = new ArticleImage 6182 { 6183 Image = new Image 6184 { 6185 Path = paragraph.GetFile("Image"), 6186 Title = imageTitle, 6187 ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, 6188 Caption = paragraph.GetString("ImageCaption") 6189 } 6190 }; 6191 articleParagraphImage.Component = image; 6192 } 6193 6194 articlePage.Add("ArticleBodyRow", articleParagraphImage); 6195 } 6196 6197 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL"))) 6198 { 6199 Block articleParagraphVideo = new Block 6200 { 6201 Id = "ArticleParagraph" + count + "Video", 6202 SortId = (count * 10) + 1, 6203 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" }, 6204 Design = new Design 6205 { 6206 RenderType = RenderType.Column, 6207 Size = imageColumns, 6208 CssClass = "u-color-light--bg u-padding--lg" 6209 } 6210 }; 6211 articlePage.Add("ArticleBodyRow", articleParagraphVideo); 6212 } 6213 6214 if (!String.IsNullOrEmpty(paragraph.GetString("Heading"))) 6215 { 6216 Block articleParagraphHeader = new Block 6217 { 6218 Id = "ArticleParagraph" + count + "Heading", 6219 SortId = (count * 10) + 2, 6220 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") }, 6221 Design = new Design 6222 { 6223 RenderType = RenderType.Column, 6224 Size = contentColumns, 6225 CssClass = "u-color-light--bg u-padding--lg" 6226 } 6227 }; 6228 articlePage.Add("ArticleBodyRow", articleParagraphHeader); 6229 } 6230 6231 if (!String.IsNullOrEmpty(text)) 6232 { 6233 Block articleParagraphText = new Block 6234 { 6235 Id = "ArticleParagraph" + count + "Text", 6236 SortId = (count * 10) + 3, 6237 Component = new ArticleText { Text = text }, 6238 Design = new Design 6239 { 6240 RenderType = RenderType.Column, 6241 Size = contentColumns, 6242 CssClass = "u-color-light--bg u-padding--lg" 6243 } 6244 }; 6245 6246 articlePage.Add("ArticleBodyRow", articleParagraphText); 6247 } 6248 } 6249 else 6250 { 6251 if (!String.IsNullOrEmpty(paragraph.GetString("Text"))) 6252 { 6253 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 6254 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : ""; 6255 6256 Block articleParagraphQuote = new Block 6257 { 6258 Id = "ArticleParagraph" + count + "Quote", 6259 SortId = (count * 10) + 3, 6260 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor }, 6261 Design = new Design 6262 { 6263 RenderType = RenderType.Column, 6264 Size = contentColumns, 6265 CssClass = "u-color-light--bg u-padding--lg" 6266 } 6267 }; 6268 articlePage.Add("ArticleBodyRow", articleParagraphQuote); 6269 } 6270 } 6271 6272 count++; 6273 } 6274 } 6275 6276 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout }; 6277 6278 6279 //Related 6280 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default"; 6281 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices; 6282 6283 if (showRelatedArtices == "true") 6284 { 6285 Block articleRelated = new Block 6286 { 6287 Id = "ArticleRelated", 6288 SortId = 30, 6289 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() }, 6290 Design = new Design 6291 { 6292 RenderType = RenderType.Column, 6293 Size = "12" 6294 } 6295 }; 6296 articlePage.Add("ArticleContainer", articleRelated); 6297 } 6298 } 6299 6300 6301 @using System 6302 @using System.Web 6303 @using System.Collections.Generic 6304 @using Dynamicweb.Rapido.Blocks 6305 6306 @{ 6307 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle"); 6308 6309 } 6310 6311 6312 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 6313 @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>