Error executing template "/Designs/Swift-v2/Grid/Page/RowTemplates/Swift-v2_Row.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5fc79f6aac9446dc83531556dfd98058.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.GridRowViewModel> @using Dynamicweb.Frontend @using System.IO @{ bool haveVideo = false; if (!string.IsNullOrEmpty(Model.Item.GetString("Video"))){ if (Model.Item.GetString("Video") != "{}"){ haveVideo = true; } } } @{ string backgroundString = ""; bool hasGradient = Model.Item.GetBoolean("BackgroundMask"); string gradientType = Model.Item.GetString("GradientType"); string angle = Model.Item.GetString("GradientAngle"); string radialType = Model.Item.GetString("GradientTypeRadial"); string color1 = Model.Item.GetString("Color"); string color2 = Model.Item.GetString("Color2"); string color3 = Model.Item.GetString("Color3"); string opacity1 = Model.Item.GetString("Opacity"); string opacity2 = Model.Item.GetString("Opacity2"); string opacity3 = Model.Item.GetString("Opacity3"); int gapSize = Model.Item.GetInt32("GapSize"); int gap = (Model?.GapX != 0 && gapSize != 0) ? gapSize : (Model?.GapX ?? 3); string imageLink = Model?.BackgroundImage?.ToString(); bool paralax = Model.Item?.GetBoolean("ParalexBackground") ?? false; Func<string, string, string> hexToRgba = (hex, opacity) => { if (string.IsNullOrWhiteSpace(hex)) return ""; var color = System.Drawing.ColorTranslator.FromHtml(hex); var safeOpacity = string.IsNullOrWhiteSpace(opacity) ? "1" : opacity.Replace(",", "."); return $"rgba({color.R}, {color.G}, {color.B}, {safeOpacity})"; }; if (hasGradient) { var stops = new List<string>(); bool hasColor1 = !string.IsNullOrWhiteSpace(color1); bool hasColor2 = !string.IsNullOrWhiteSpace(color2); bool hasColor3 = !string.IsNullOrWhiteSpace(color3); if (hasColor1) stops.Add($"{hexToRgba(color1, opacity1)} 0%"); if (hasColor2) stops.Add($"{hexToRgba(color2, opacity2)} 50%"); if (hasColor3) stops.Add($"{hexToRgba(color3, opacity3)} 100%"); if (stops.Count == 1) stops.Add($"{hexToRgba(color1, opacity1)} 100%"); if (gradientType == "linear-gradient") { backgroundString = $"linear-gradient({angle}deg, {string.Join(", ", stops)})"; } else if (gradientType == "radial-gradient") { var radial = string.IsNullOrWhiteSpace(radialType) ? "circle" : radialType; backgroundString = $"radial-gradient({radial}, {string.Join(", ", stops)})"; } } var finalBackgroundStyle = ""; var finalMobileBackgroundStyle = ""; string paralaxImage = ""; if (paralax){ paralaxImage = " background-parallax"; } if (!string.IsNullOrWhiteSpace(imageLink)) { string imageStyle = $"url('/admin/public/GetImage.ashx?width=1680&format=WebP&image={imageLink}')"; string imageStyleMobile = $"url('/admin/public/GetImage.ashx?width=1080&Ratio=3/4&format=WebP&image={imageLink}')"; if (!string.IsNullOrWhiteSpace(backgroundString)) { finalBackgroundStyle = $"background: {backgroundString}, {imageStyle}; background-size: cover;"; finalMobileBackgroundStyle = $"background: {backgroundString}, {imageStyleMobile}; background-size: cover;"; } else { finalBackgroundStyle = $"background-image: {imageStyle}; background-size: cover;"; finalMobileBackgroundStyle = $"background-image: {imageStyleMobile}; background-size: cover;"; } if (paralax) { finalBackgroundStyle += " background-attachment: fixed; background-position: center;"; finalMobileBackgroundStyle += " background-attachment: fixed; background-position: center;"; } } else if (!string.IsNullOrWhiteSpace(backgroundString)) { finalBackgroundStyle = $"background: {backgroundString}; --dw-row-background: {backgroundString};"; finalMobileBackgroundStyle = $"background: {backgroundString};"; } } <section class="@(paralaxImage) @(Model.Item.GetString("Custom_Class"))" data-swift-gridrow style="@(finalBackgroundStyle)" data-dw-colorscheme="@Model?.ColorScheme?.Id" data-dw-itemtype="@Model?.Item?.SystemName.ToLower()" data-dw-row-space-top="@(Model?.TopSpacing ?? 6)" data-dw-row-space-bottom="@(Model?.BottomSpacing ?? 6)" data-dw-row-gap-column="@(gap)" data-dw-row-gap-row="@(gap)" data-dw-row-vertical-align="@(Model?.VerticalAlignment)" data-dw-custom-havevideo="@(haveVideo)" data-dw-custom-paralexbackground="@Model.Item?.GetBoolean("ParalexBackground")" data-dw-custom-gradient="@(hasGradient)" > @if (paralax){ <div class="parallax-image-safari" style="@(finalMobileBackgroundStyle)" ></div> } <div data-swift-container class="grid" data-dw-container-width="@(Model?.ContainerWidth ?? 3)"> @foreach(var column in Model.Columns) { string customClass = Model.Item.GetString("CustomClassColumn" + column.ColumnNumber) ?? string.Empty; <div data-swift-gridcolumn class="g-col-@column.ColumnWidthMobile g-col-lg-@column.ColumnWidth order-@column.ColumnNumberMobile order-lg-@column.ColumnNumber @(customClass)" data-dw-itemtype="@column.Paragraph?.Item?.SystemName.ToLower()" id="@column.Paragraph?.ID" data-dw-colorscheme="@column.Paragraph?.ColorScheme?.Id"> @column.Output() </div> } </div> @if(Model.Item.TryGetVideo("Video", out VideoViewModel video)) { <figure class="position-absolute top-0 bottom-0 end-0 start-0 m-0 pe-none ratio overflow-hidden" itemscope itemtype="https://schema.org/VideoObject"> @if (video.IsExternalLink()) { <iframe src="@(video.ToEmbedUrl())?autoplay=1&controls=0&showinfo=0&rel=0&mute=1&muted=1&loop=1&autopause=0&background=0" class="object-fit-cover" title="@video.Name" frameborder="0" allow="fullscreen; autoplay;encrypted-media;"></iframe> } else { <video preload="auto" loop autoplay muted playsinline class="object-fit-cover"> <source playsinline src="@(video.Path)" type="video/@Path.GetExtension(video.Path).ToLower().Replace(".", string.Empty)"> </video> } </figure> } </section>
Denne hjemmeside bruger cookies
Vi bruger cookies til at tilpasse vores indhold og annoncer, til at vise dig funktioner til sociale medier og til at analysere vores trafik. Vi deler også oplysninger om din brug af vores website med vores partnere inden for sociale medier, annonceringspartnere og analysepartnere. Vores partnere kan kombinere disse data med andre oplysninger, du har givet dem, eller som de har indsamlet fra din brug af deres tjenester. Du samtykker til vores cookies, hvis du fortsætter med at anvende vores hjemmeside.