• Gratis Versand ab 50€
  • Vor 17:00 bestellt, Versand am selben Werktag
  • Zahlung per Rechnung
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Exception in template (Designs/Ongediertewinkel_generated/Paragraph/Carousel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.dbebeeebcdab.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateBase.cs:line 126
at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 608
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 439
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Razor.cs:line 290
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb; @using Dynamicweb.Content.Items; @using Bluedesk.DynamicWeb.ItemTypes; @using Bluedesk.DynamicWeb.ItemTypes.Pages; @using Bluedesk.Tools.DynamicWeb.ExtensionMethods; @using Bluedesk.Tools.Generic.ExtensionMethods @using System.Linq; @using Dynamicweb.Content; <!-- FIX NEEDED: behaviour when all the items are full height images (for instance logo slider)?? --> @{ Carousel _data = ItemManager.Storage.GetById<Carousel>(Pageview.CurrentParagraph.ItemId ?? "0"); var paragraphID = Pageview.CurrentParagraph.ID; int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var classFullWidth = !_data.Fullwidth ? "container" : "w-full"; // If slider or multicolumn has to be in container or full width of the page } @if (amountColumns > 0) { <style> @@media only screen and (max-width: 768px) { .carousel-cell-wrap { width: 100% !important; } } </style> <div class="cta-container multicolumn overflow-hidden @backgroundClass @_data.CssClass" data-paragraphid="@paragraphID" id="@paragraphID"> <div class="@classFullWidth">@RenderContentArea(_data)</div> </div> } @helper RenderContentArea(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user var backgroundClass = !string.IsNullOrWhiteSpace(_data.BackgroundConfiguration.BackgroundClass) ? string.Format("bg-{0}", _data.BackgroundConfiguration.BackgroundClass) : ""; var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; // bool clickableBlock = _data.Clickable; // string clickableClass = clickableBlock ? "cta-paragraph--clickable" : ""; string centerTextClass = _data.CenterText ? "items-center text-center" : "items-start text-left"; /* Specific for Carousel */ int colDisplay = _data.ColumnsDisplay; // Amount of displayed column within one screen bool fullWidth = _data.Fullwidth; // If slider or multicolumn has to be in container or full widthof the page bool infiniteLoop = _data.Infinite; bool autoPlay = _data.AutoPlay; bool controls = _data.AddControls; bool duration = _data.Duration; bool showDots = _data.ShowDots; // If slider or multicolumn has to be in container or full widthof the page int colAmount = 1; bool imagesOnlyBool = checkOnlyImages(_data); // Check if this carousel contains only images (logo slider) if (!string.IsNullOrWhiteSpace(@_data.Header.HeaderFormatted())) { <header class="multicolumn__header-wrapper"> @_data.Header.HeaderFormatted("multicolumn__header") </header> } string carouselHeight = "auto"; if (imagesOnlyBool && _data.ImageHeight != 0) { carouselHeight = _data.ImageHeight.ToString() + "px"; } if ((colDisplay <= amountColumns) && (colDisplay != 0)) { string flexBasis = 100 / @colDisplay + "%"; <section class="carousel multicolumn" data-columns="@colAmount" data-dots="@showDots" data-loop="@infiniteLoop" data-autoplay="@autoPlay" data-controls="@controls" data-duration="@duration" style="height: @carouselHeight;"> @foreach (var column in _data.CarouselItems) { Boolean hasContent = !string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()); string image = column.Image.Image; string imagesHeight = _data.ImageHeight == 0 ? "auto" : _data.ImageHeight.ToString() + "px"; string ImageContainerFixed = hasContent ? "cta-paragraph__image-container--fixed" : ""; string ImageAsBackground = (column.BackgroundConfiguration.ConfigurationName == "Image as Background") ? "cta-paragraph__image--is-background" : ""; string coverImage = ""; string newWindow = column.Button.NewWindow ? "target='_blank'" : ""; string figureHeight = !hasContent ? "flex-grow:1" : "height:" + imagesHeight; string TempClass = imagesOnlyBool ? "imageOnly" : "hasContent"; string ImageOnlyImageHeight = imagesOnlyBool ? "height:"+imagesHeight+";" : "height:auto;"; string clickableClass = !string.IsNullOrWhiteSpace(column.Button.ButtonLink) ? "cta-paragraph--clickable" : ""; if (!imagesOnlyBool) { imagesHeight = hasContent ? imagesHeight : imagesHeight = "100%"; } /*This is work around created by Alla to enable cover mode for stand alone pictures*/ if (!hasContent && column.Image.BackgroundSize == "bg-cover") { coverImage = "height:100%;"; } <div class="carousel-cell-wrap" style="display: flex; @ImageOnlyImageHeight width: @flexBasis; min-height:100%; @coverImage"> <section class="carousel__wrapper carousel-item carousel-cell @clickableClass" style="min-height: @imagesHeight; @ImageOnlyImageHeight"> @if (!string.IsNullOrWhiteSpace(column.Image.Image)) { <!-- <figure class="cta-paragraph__image-container @ImageContainerFixed @ImageAsBackground @column.Image.PositionY @column.Image.PositionX" style="min-height: @imagesHeight;"> <img src="@image" alt="@column.Image.ImageAlt" class="cta-paragraph__image carousel-image @column.Image.BackgroundSize" /> </figure> --> <figure style="@figureHeight; " class="carousel__image-container flex items-center justify-center @TempClass @column.Image.PositionX @column.Image.PositionY @column.Image.BackgroundSize"> <img src="@image" class="carousel__image" alt="@column.Image.ImageAlt" /> </figure> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText) || !string.IsNullOrWhiteSpace(column.Content.Text) || !string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <div class="carousel__content-container @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted()) || !string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="carousel__content"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <div class="cta-paragraph__text">@column.Content.Text</div> } </section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link carousel__cta @column.Button.Configuration.ButtonClass"> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> <!-- <div class="cta-paragraph__content @centerTextClass"> @if (!string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { <header class="cta-paragraph__header">@column.Header.HeaderFormatted("cta-paragraph__header")</header> } @if (!string.IsNullOrWhiteSpace(column.Content.Text)) { <section class="cta-paragraph__text" style="max-width: 24rem;">@column.Content.Text</section> } @if (!string.IsNullOrWhiteSpace(column.Button.ButtonText)) { <a href="@column.Button.ButtonLink" class="btn cta-paragraph__btn cta-paragraph__link @column.Button.Configuration.ButtonClass" @newWindow> <span class="btn__text cta-paragraph__btn-label">@column.Button.ButtonText</span> <i class="btn__icon cta-paragraph__btn-icon @buttonIconClass"></i> </a> } </div> --> } @if (!string.IsNullOrWhiteSpace(@column.Button.ButtonLink)) { <a href="@column.Button.ButtonLink" class="cta-paragraph__clickable" @newWindow></a> } </section> </div> } </section> } else if (colDisplay > amountColumns) { <div>Error: you cant display columns more than you filled in the backend</div> } } @functions{ // Check if this carousel contains only images (logo slider) bool checkOnlyImages(Carousel _data) { int amountColumns = _data.CarouselItems.Count; // Amount of the columns in backend, filled by user int emptyColumn = 0; // Loop through all the columns foreach (var column in _data.CarouselItems) { // If button is empty AND content is empty AND header is empty => this is img only if (string.IsNullOrWhiteSpace(column.Button.ButtonText) && string.IsNullOrWhiteSpace(column.Content.Text) && string.IsNullOrWhiteSpace(column.Header.HeaderFormatted())) { emptyColumn++; } } bool emptyColumnResult = emptyColumn == amountColumns ? true : false; return emptyColumnResult; } }
Oben