Welcome autumn

Experience our autumn 2022 collection

Error executing template "/Designs/Swift/Grid/Page/RowTemplates/2Columns_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_cf8c21c885534333a53d46dcfe444f31.Execute() in D:\dynamicweb.net\Solutions\twodayco3\evasolo.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Grid\Page\RowTemplates\2Columns_Custom.cshtml:line 7
   at 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.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using Dynamicweb.Content.Files.Metadata 2 @using Dynamicweb.Frontend 3 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.GridRowViewModel> 4 5 @{ 6 string sectionClass = "py-3"; 7 string spaceBetweenRows = Model.Item.GetRawValueString("SpaceBetweenRows", "spacing"); 8 string spaceBetweenRowsMobile = Model.Item.GetRawValueString("SpaceBetweenRowsMobile", "auto"); 9 //Mobile 10 if(spaceBetweenRowsMobile == "auto") 11 { 12 spaceBetweenRowsMobile = spaceBetweenRows; 13 } 14 if (spaceBetweenRowsMobile == "none") 15 { 16 sectionClass = "py-0"; 17 } 18 if (spaceBetweenRowsMobile == "spacing") 19 { 20 sectionClass = "py-3"; 21 } 22 if (spaceBetweenRowsMobile == "spacing-large") 23 { 24 sectionClass = "py-5"; 25 } 26 if (spaceBetweenRowsMobile == "spacing-small-top") 27 { 28 sectionClass = "pt-3"; 29 } 30 if (spaceBetweenRowsMobile == "spacing-small-bottom") 31 { 32 sectionClass = "pb-3"; 33 } 34 if (spaceBetweenRowsMobile == "spacing-top") 35 { 36 sectionClass = "pt-5"; 37 } 38 if (spaceBetweenRowsMobile == "spacing-bottom") 39 { 40 sectionClass = "pb-5"; 41 } 42 //Desktop 43 if (spaceBetweenRows == "none") 44 { 45 sectionClass += " py-lg-0"; 46 } 47 if (spaceBetweenRows == "spacing") 48 { 49 sectionClass += " py-lg-3"; 50 } 51 if (spaceBetweenRows == "spacing-large") { 52 sectionClass += " py-lg-6"; 53 } 54 if (spaceBetweenRows == "spacing-small-top") 55 { 56 sectionClass += " pt-lg-3 pb-lg-0 "; 57 } 58 if (spaceBetweenRows == "spacing-small-bottom") 59 { 60 sectionClass += " pb-lg-3 pt-lg-0"; 61 } 62 if (spaceBetweenRows == "spacing-top") { 63 sectionClass += " pt-lg-6 pb-lg-0 "; 64 } 65 if (spaceBetweenRows == "spacing-bottom") { 66 sectionClass += " pb-lg-6 pt-lg-0"; 67 } 68 69 string containerClass = "container-xl"; 70 string width = Model.Item.GetRawValueString("Width", "container-xl"); 71 if (width == "none") 72 { 73 containerClass = string.Empty; 74 } 75 if (width == "stretch") { 76 containerClass = "container-fluid"; 77 } 78 if (width == "compressed") { 79 containerClass = " container-compressed"; 80 } 81 82 string rowClass = string.Empty; 83 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", string.Empty).ToLower(); 84 string spaceBetweenColumnsMobile = Model.Item.GetRawValueString("SpaceBetweenColumnsMobile", string.Empty).ToLower(); 85 //Mobile 86 if (spaceBetweenColumnsMobile == "auto") 87 { 88 spaceBetweenColumnsMobile = spaceBetweenColumns; 89 } 90 if (spaceBetweenColumnsMobile == "stick") { 91 rowClass = " gap-0"; 92 } 93 if (spaceBetweenColumnsMobile == "spacing-medium") 94 { 95 rowClass = " gap-4"; 96 } 97 if (spaceBetweenColumnsMobile == "spacing-large") { 98 rowClass = " gap-5"; 99 } 100 //Desktop 101 if (spaceBetweenColumns == "stick") { 102 rowClass += " gap-lg-0"; 103 } 104 if (spaceBetweenColumns == "spacing-medium") 105 { 106 rowClass += " gap-lg-4"; 107 } 108 if (spaceBetweenColumns == "spacing-large") { 109 rowClass += " gap-lg-5"; 110 } 111 112 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 113 114 string animationOnScrollCol1 = Model.Item.GetRawValueString("AnimationOnScrollCol1", "no-animation"); 115 animationOnScrollCol1 = animationOnScrollCol1 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol1 + "'" : ""; 116 string animationOnScrollCol2 = Model.Item.GetRawValueString("AnimationOnScrollCol2", "no-animation"); 117 animationOnScrollCol2 = animationOnScrollCol2 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol2 + "'" : ""; 118 119 string hideOverflow = " overflow-hidden"; 120 hideOverflow = 121 animationOnScrollCol1 != "" || 122 animationOnScrollCol2 != "" 123 ? hideOverflow : ""; 124 125 Dynamicweb.Frontend.FileViewModel backgroundImage = Model.Item.GetFile("BackgroundImage"); 126 string backgroundImagePath = backgroundImage?.Path ?? string.Empty; 127 string imagePath = $"/Admin/Public/GetImage.ashx?image={backgroundImagePath}&width=960&format=webp"; 128 backgroundImagePath = Dynamicweb.Core.Encoders.HtmlEncoder.UrlEncodeUnicode(backgroundImagePath); 129 string backgroundRepeat = Model.Item.GetRawValueString("BackgroundImageRepeat", "no-repeat"); 130 string backgroundImageSize = Model.Item.GetRawValueString("BackgroundImageSize", "initial"); 131 int xPos = backgroundImage?.FocalPositionFromLeft ?? 50; 132 int yPos = backgroundImage?.FocalPositionFromTop ?? 50; 133 string cssPosition = $"{xPos}% {yPos}%"; 134 string gradient = Model.Item.GetRawValueString("Gradient", string.Empty); 135 string gradientOpacity = Model.Item.GetRawValueString("GradientOpacity", "0.00"); 136 string gradientString = "linear-gradient(" + gradient + "deg," + "rgba(var(--swift-foreground-color-rgb)," + gradientOpacity + "), rgba(var(--swift-background-color-rgb)," + gradientOpacity + "))"; 137 string backgroundImageString = "url(" + backgroundImagePath + ")"; 138 string backgroundImagePositionString = "background-position:" + cssPosition + ";"; 139 string backgroundRepeatString = "background-repeat:" + backgroundRepeat + ";"; 140 string backgroundImageSizeString = "background-size:" + backgroundImageSize + ";"; 141 string styleString = string.Empty; 142 143 @* Only gradient *@ 144 145 if (!string.IsNullOrEmpty(gradient) && string.IsNullOrEmpty(backgroundImagePath) && gradientOpacity != ("0.00")) 146 { 147 styleString += "style=\"background-image:" + gradientString + ";\""; 148 } 149 150 @* Only background image *@ 151 152 else if (string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath)) 153 { 154 styleString += "style=\"background-image:" + backgroundImageString + "," + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\""; 155 } 156 157 @* Gradient and background image *@ 158 159 else if (!string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath)) 160 { 161 styleString += "style=\"background-image:" + gradientString + "," + backgroundImageString + ";" + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\""; 162 } 163 164 @* Custom *@ 165 166 string customColumnOne = "g-col-lg-6"; 167 string customColumnTwo = "g-col-lg-6"; 168 169 Dictionary<string, string> customFields = new Dictionary<string, string>(); 170 171 foreach (var customItemFields in Model.Item.Fields.Where(f => f.SystemName == "ColumnLayout")) 172 { 173 if (customItemFields.GetItem().Fields != null) 174 { 175 foreach (ItemFieldViewModel field in customItemFields.GetItem().Fields) 176 { 177 customFields.Add(field.SystemName, field.GetRawValueString()); 178 } 179 } 180 } 181 182 if (customFields["Layout"] == "primary") 183 { 184 customColumnOne = "g-col-lg-4 g-start-lg-2"; 185 customColumnTwo = "g-col-lg-5 g-start-lg-7"; 186 } else if (customFields["Layout"] == "secondary") 187 { 188 customColumnOne = "g-col-lg-5 g-start-lg-2"; 189 customColumnTwo = "g-col-lg-4 g-start-lg-8"; 190 } else if (customFields["Layout"] == "tertiary") 191 { 192 customColumnOne = "g-col-md-6 g-col-lg-7"; 193 customColumnTwo = "g-col-md-6 g-col-lg-5"; 194 } 195 196 } 197 198 <div class="@(sectionClass)@(theme) item_@Model.Item.SystemName.ToLower()" @styleString> 199 <div class="@containerClass@(hideOverflow)"> 200 <div class="grid @rowClass"> 201 <div class="g-col-12 @customColumnOne" data-col-size="6" @animationOnScrollCol1 data-aos="fade" data-aos-duration="1000"> 202 @Model.Column(1).Output() 203 </div> 204 <div class="g-col-12 @customColumnTwo" data-col-size="6" @animationOnScrollCol2 data-aos="fade" data-aos-duration="1000" data-aos-delay="250"> 205 @Model.Column(2).Output() 206 </div> 207 </div> 208 </div> 209 </div> 210

Sage

The colour taps into the modern home with natural ambience for a sophisticated style-refresh.

Chocolate

Immerse yourself in the appeal of chocolate