• 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_ee916ec13cb94da1be4a1aaa46d91485.Execute() in D:\home\site\wwwroot\files\Templates\Designs\Ongediertewinkel_generated\Paragraph\Carousel.cshtml:line 17at 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 16 var paragraphID = Pageview.CurrentParagraph.ID; 17 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user 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 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 22 @using Dynamicweb; 23 @using Dynamicweb.Content.Items; 24 @using Bluedesk.DynamicWeb.ItemTypes; 25 26 27 @{ 28 string fullWidthContainerClass = _data.Fullwidth ? "" : "container"; 29 30 string backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; 31 string backgroundStyle = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundColor) ? $"background-color: {_data.BackgroundConfiguration.BackgroundColor}; " : ""; 32 backgroundStyle += !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundImage) ? $"background-image: url({_data.BackgroundConfiguration.BackgroundImage}); " : ""; 33 } 34 35 36 @functions { 37 string getbackgroundclass(string backgroundClass) 38 { 39 return !string.IsNullOrWhiteSpace(backgroundClass) ? string.Format("bg-{0}" ,backgroundClass) : ""; 40 } 41 } 42 43 @helper CTAParagraphImage(ParagraphImageResizable Image, bool ImageAsBackground, string ImagePosition, bool ParallaxImage, bool Fullwidth, string imagesHeight) 44 { 45 if (!string.IsNullOrWhiteSpace(Image.Image)) 46 { 47 48 string image = !string.IsNullOrWhiteSpace(Image.Image) ? Image.Image : null; 49 imagesHeight = !string.IsNullOrWhiteSpace(imagesHeight) ? "height: " + imagesHeight + ";" : ""; 50 51 string imageParrallax = ParallaxImage ? "rellax" : ""; 52 string imageAsBackground = ImageAsBackground ? "cta-paragraph__image--is-background" : ""; 53 int imageWidth = 2000; 54 55 imageWidth = Fullwidth ? imageWidth : 1200; 56 57 string strImageWidth = imageWidth + "px"; 58 string strImageWidthSize = imageWidth + "w"; 59 60 string ImageUrl = "/Admin/Public/GetImage.ashx?Image=" + image + "&Crop=0&Compression=80"; 61 62 if (!string.IsNullOrWhiteSpace(Image.Image)) 63 { 64 <figure class="cta-paragraph__image-container @imageAsBackground @Image.PositionY @Image.PositionX" style="@imagesHeight"> 65 66 <picture class="cta-paragraph__image @Image.BackgroundSize @imageParrallax"> 67 <source media="(max-width: 400px)" srcset="@ImageUrl&Width=400"> 68 <source media="(max-width: 994px)" srcset="@ImageUrl&Width=994"> 69 <img src="@ImageUrl&Width=@imageWidth" alt="@Image.ImageAlt" class="cta-paragraph__image @Image.BackgroundSize @imageParrallax"> 70 </picture> 71 72 </figure> 73 } 74 } 75 } 76 77 78 @helper CTAParagraphContent(ParagraphHeader Header, ParagraphHeader SubHeader, ParagraphContent Content, CTAButton Button, ParagraphImage Image, bool strCenterVertical) 79 { 80 81 bool hasImage = !string.IsNullOrWhiteSpace(Image.Image) ? true : false; 82 string noImageClass = hasImage ? "" : "no-image"; 83 84 string centerTextClass = strCenterVertical ? "text-center" : ""; 85 string centerContent = !string.IsNullOrWhiteSpace(Image.Image) ? "" : "cta-paragraph__content--center"; 86 87 string buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; 88 89 if (!string.IsNullOrWhiteSpace(Button.ButtonText) || !string.IsNullOrWhiteSpace(Content.Text) || !string.IsNullOrWhiteSpace(Header.HeaderFormatted("cta-paragraph__header"))) 90 { 91 <section class="cta-paragraph__content @centerContent @noImageClass"> 92 93 <article class="cta-paragraph__content-container @centerTextClass @noImageClass"> 94 95 @if (!string.IsNullOrWhiteSpace(Header.HeaderFormatted("cta-paragraph__header"))) 96 { 97 <header class="cta-paragraph__header"> 98 @if (SubHeader != null) 99 {100 @SubHeader.HeaderFormatted("cta-paragraph__subheader")101 }102 @Header.HeaderFormatted("cta-paragraph__header")103 </header>104 }105106 @if (!string.IsNullOrWhiteSpace(Content.Text))107 {108 <div class="cta-paragraph__text @centerTextClass">@Content.Text</div>109 }110111 </article>112113 @if (!string.IsNullOrWhiteSpace(Button.ButtonLink))114 {115 <a href="@Button.ButtonLink" class="btn cta-paragraph__btn @Button.Configuration.ButtonClass">116 <span class="btn__text cta-paragraph__btn-label">@Button.ButtonText</span>117 <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i>118 </a>119 }120121 </section>122123 }124125 }126127128 @if (amountColumns > 0)129 {130 <div class="multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID">131 <div class="@classFullWidth">@RenderContentArea(_data)</div>132 </div>133 }134135 @helper RenderContentArea(Carousel _data)136 {137 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user138 var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right";139140 string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left";141142 /* Specific for Carousel */143144 int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen145146 bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page147 bool infiniteLoop = _data.Infinite;148 bool autoPlay = _data.AutoPlay;149 bool controls = _data.AddControls;150 bool duration = _data.Duration;151 bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page152 int colAmount = 1;153154 bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider)155156 if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted()))157 {158 <header class="multicolumn__header-wrapper">159 @_data.Header.HeaderFormatted("multicolumn__header")160 </header>161 }162163 string carouselHeight = "auto";164165 if (imagesOnlyBool && _data.ImageHeight != 0)166 {167 carouselHeight = _data.ImageHeight.ToString() + "px";168 }169170 if ((colDisplay <= amountColumns) && (colDisplay != 0))171 {172 string flexBasis = 100 / @colDisplay + "%";173174 <section class="carousel multicolumn"175 data-columns="@colAmount"176 data-dots="@showDots"177 data-loop="@infiniteLoop"178 data-autoplay="@autoPlay"179 data-controls="@controls"180 data-duration="@duration"181 style="height: @carouselHeight;">182183 @foreach (var column in _data.CarouselItems)184 {185186 Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted());187188 string image = column.Image.Image;189 string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px";190 string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : "";191 string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : "";192193 string coverImage = "";194195 string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight;196 string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent";197 string ImageOnlyImageHeight = imagesOnlyBool ? "height:" + imagesHeight + ";" : "height:auto;";198199 if (!imagesOnlyBool)200 {201 imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%";202 }203204 /*This is work around created by Alla to enable cover mode for stand alone pictures*/205 if (!hasContent && column.Image.BackgroundSize == "bg-cover")206 {207 coverImage = "height:100%;";208 }209210 <div class="carousel-cell-wrap" style="display: flex; min-height:100%; @ImageOnlyImageHeight width: @flexBasis; @coverImage">211212 <section class="cta-paragraph carousel-cell" style="min-height: @imagesHeight; @ImageOnlyImageHeight">213 @{214 string newWindow = column.Button.NewWindow ? "target='_blank'" : "";215216 bool clickableBlock = !string.IsNullOrWhiteSpace(column.Button.ButtonLink);217 string clickableClass = clickableBlock ? "cta-paragraph__container--clickable" : "";218 }219220 @CTAParagraphImage(221 column.Image,222 false,223 null,224 false,225 false,226 imagesHeight227 )228 @CTAParagraphContent(229 column.Header,230 null,231 column.Content,232 column.Button,233 column.Image,234 false235 )236237 @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink))238 {239 <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a>240 }241 </section>242243 </div>244 }245 </section>246 }247 else if (colDisplay > amountColumns)248 {249 <div>Error: you cant display columns more than you filled in the backend</div>250 }251 }252253 @functions{254 // Check if this carousel contains only images (logo slider)255 bool checkOnlyImages(Carousel _data)256 {257258 int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user259 int emptyColumn = 0;260261 // Loop through all the columns262 foreach (var column in _data.CarouselItems)263 {264 // If button is empty AND content is empty AND header is empty => this is img only265 if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()))266 {267 emptyColumn++;268 }269 }270271 bool emptyColumnResult = emptyColumn == amountColumns ? true : false;272273 return emptyColumnResult;274275 }276 }277
Naar boven