Error executing template "/Designs/Swift/Grid/Page/RowTemplates/1ColumnComponentEdit.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_b5b6234f23d444eb8976bfb1b7af632c.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>
@{
string pushDown = "";
string columnPosition = Model.Item.GetRawValueString("ColumnPosition", "align-items-center").ToLower();
if (columnPosition == "bottom")
{
pushDown = " mt-auto";
}
string spaceBetweenRows = Model.Item.GetRawValueString("SpaceBetweenRows", "spacing");
string sectionClass = string.Empty;
//Row spacing dekstop
switch (spaceBetweenRows) {
case "none": //No spacing
sectionClass += "py-0";
break;
case "spacing": //Small spacing top and bottom
sectionClass += "py-2";
break;
case "spacing-small-top": //Small spacing top
sectionClass += "pt-2";
break;
case "spacing-small-bottom": //Small spacing bottom
sectionClass += "pb-2";
break;
case "spacing-medium": //Medium spacing top and bottom
sectionClass += "py-3";
break;
case "spacing-medium-top": //Medium spacing top
sectionClass += "pt-3";
break;
case "spacing-medium-bottom": //Medium spacing bottom
sectionClass += "pb-3";
break;
case "spacing-large": //Large spacing top and bottom
sectionClass += "py-4";
break;
case "spacing-top": //Large spacing top
sectionClass += "pt-4";
break;
case "spacing-bottom": //Large spacing bottom
sectionClass += "pb-4";
break;
}
string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>();
var css = string.Empty;
var cssClasses = new List<string> { };
foreach (var itemId in decorations)
{
var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId);
item.TryGetValue("Class", out object classes);
if (classes is null)
{
continue;
}
var cssString = (string)classes;
if (cssString.StartsWith("["))
{
var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString);
cssClasses.AddRange(cssArray);
}
else
{
cssClasses.Add(cssString.Replace(",", " "));
}
}
css = string.Join(" ", cssClasses).Trim();
string columnOne = Model.Column(1).Output().Trim();
if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnOne))
{
<div class="@(theme)@(pushDown) @(css) item_@Model.Item.SystemName.ToLower()">
<div class="@sectionClass" data-col-size="12">
@columnOne
</div>
</div>
}
}
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/1ColumnComponentEdit.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_b5b6234f23d444eb8976bfb1b7af632c.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>
@{
string pushDown = "";
string columnPosition = Model.Item.GetRawValueString("ColumnPosition", "align-items-center").ToLower();
if (columnPosition == "bottom")
{
pushDown = " mt-auto";
}
string spaceBetweenRows = Model.Item.GetRawValueString("SpaceBetweenRows", "spacing");
string sectionClass = string.Empty;
//Row spacing dekstop
switch (spaceBetweenRows) {
case "none": //No spacing
sectionClass += "py-0";
break;
case "spacing": //Small spacing top and bottom
sectionClass += "py-2";
break;
case "spacing-small-top": //Small spacing top
sectionClass += "pt-2";
break;
case "spacing-small-bottom": //Small spacing bottom
sectionClass += "pb-2";
break;
case "spacing-medium": //Medium spacing top and bottom
sectionClass += "py-3";
break;
case "spacing-medium-top": //Medium spacing top
sectionClass += "pt-3";
break;
case "spacing-medium-bottom": //Medium spacing bottom
sectionClass += "pb-3";
break;
case "spacing-large": //Large spacing top and bottom
sectionClass += "py-4";
break;
case "spacing-top": //Large spacing top
sectionClass += "pt-4";
break;
case "spacing-bottom": //Large spacing bottom
sectionClass += "pb-4";
break;
}
string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>();
var css = string.Empty;
var cssClasses = new List<string> { };
foreach (var itemId in decorations)
{
var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId);
item.TryGetValue("Class", out object classes);
if (classes is null)
{
continue;
}
var cssString = (string)classes;
if (cssString.StartsWith("["))
{
var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString);
cssClasses.AddRange(cssArray);
}
else
{
cssClasses.Add(cssString.Replace(",", " "));
}
}
css = string.Join(" ", cssClasses).Trim();
string columnOne = Model.Column(1).Output().Trim();
if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnOne))
{
<div class="@(theme)@(pushDown) @(css) item_@Model.Item.SystemName.ToLower()">
<div class="@sectionClass" data-col-size="12">
@columnOne
</div>
</div>
}
}