• Gratis verzending vanaf €40,-
  • Voor 17:30 uur besteld, morgen in huis!
  • Achteraf betalen
Error executing template "Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml"System.NullReferenceException: Object reference not set to an instance of an object.at CompiledRazorTemplates.Dynamic.RazorEngine_2189d230062d445396f181551a81a7a1.Execute() in D:\home\site\wwwroot\files\Templates\Designs\Ongediertewinkel_generated\Paragraph\Carousel.cshtml:line 16at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb; 3 @using Dynamicweb.Content.Items; 4 @using Bluedesk.DynamicWeb.ItemTypes; 5 @using Bluedesk.DynamicWeb.ItemTypes.Pages; 6 @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; 7 @using Bluedesk.Tools.Generic.ExtensionMethods 8 @using System.Linq; 9 @using Dynamicweb.Content; 10 11 <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> 12 13 @{ 14 Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); 15 var paragraphID = Pageview.CurrentParagraph.ID; 16 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user 17 var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; 18 var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page 19 } 20 21 @if (amountColumns > 0) 22 { 23 <style> 24 @@media only screen and (max-width: 768px) { 25 .carousel-cell-wrap { 26 width: 100% !important; 27 } 28 } 29 </style> 30 31 <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> 32 <div class="@classFullWidth">@RenderContentArea(_data)</div> 33 </div> 34 } 35 36 @helper RenderContentArea(Carousel _data) 37 { 38 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user 39 var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; 40 var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; 41 42 // bool clickableBlock = _data.Clickable; 43 // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; 44 string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; 45 46 /* Specific for Carousel */ 47 48 int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen 49 50 bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page 51 bool infiniteLoop = _data.Infinite; 52 bool autoPlay = _data.AutoPlay; 53 bool controls = _data.AddControls; 54 bool duration = _data.Duration; 55 bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page 56 int colAmount = 1; 57 58 bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) 59 60 if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) 61 { 62 <header class="multicolumn__header-wrapper"> 63 @_data.Header.HeaderFormatted("multicolumn__header") 64 </header> 65 } 66 67 string carouselHeight = "auto"; 68 69 if (imagesOnlyBool && _data.ImageHeight != 0) 70 { 71 carouselHeight = _data.ImageHeight.ToString() + "px"; 72 } 73 74 if ((colDisplay <= amountColumns) && (colDisplay != 0)) 75 { 76 string flexBasis = 100 / @colDisplay + "%"; 77 78 <section class="carousel multicolumn" 79 data-columns="@colAmount" 80 data-dots="@showDots" 81 data-loop="@infiniteLoop" 82 data-autoplay="@autoPlay" 83 data-controls="@controls" 84 data-duration="@duration" 85 style="height: @carouselHeight;"> 86 87 @foreach (var column in _data.CarouselItems) 88 { 89 90 Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); 91 92 string image = column.Image.Image; 93 string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; 94 string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; 95 string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; 96 97 string coverImage = ""; 98 string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; 99100 string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight;101 string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent";102 string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;";103104 string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : "";105106 if (!imagesOnlyBool)107 {108 imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%";109 }110111 /*This is work around created by Alla to enable cover mode for stand alone pictures*/112 if (!hasContent && column.Image.BackgroundSize == "bg-cover")113 {114 coverImage = "height:100%;";115 }116117 <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage">118119 <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight">120121 @if (!string.IsNullOrWhiteSpace(column.Image.Image))122 {123 <!--124 <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;">125 <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" />126 </figure>127 -->128129 <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize">130 <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" />131 </figure>132 }133134 @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()))135 {136137 <div class="carousel__content-container @centerTextClass">138139 @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text))140 {141 <section class="carousel__content">142 @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()))143 {144 <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header>145 }146 @if (!string.IsNullOrWhiteSpace(column.Content.Text))147 {148 <div class="cta-paragraph__text">@column.Content.Text</div>149 }150 </section>151 }152 @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText))153 {154 <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass">155 <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span>156 <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i>157 </a>158 }159 </div>160161 <!--162 <div class="cta-paragraph__content @centerTextClass">163164 @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()))165 {166 <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header>167 }168169 @if (!string.IsNullOrWhiteSpace(column.Content.Text))170 {171 <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section>172 }173174 @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText))175 {176 <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow>177 <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span>178 <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i>179 </a>180 }181182 </div>183 -->184185 }186187 @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink))188 {189 <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a>190 }191192 </section>193 </div>194 }195 </section>196 }197 else if (colDisplay > amountColumns)198 {199 <div>Error: you cant display columns more than you filled in the backend</div>200 }201 }202203 @functions{204 // Check if this carousel contains only images (logo slider)205 bool checkOnlyImages(Carousel _data)206 {207208 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user209 int emptyColumn = 0;210211 // Loop through all the columns212 foreach (var column in _data.CarouselItems)213 {214 // If button is empty AND content is empty AND header is empty => this is img only215 if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()))216 {217 emptyColumn++;218 }219 }220221 bool emptyColumnResult = emptyColumn == amountColumns ? true : false;222223 return emptyColumnResult;224225 }226 }227
Naar boven