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