Error executing template "Designs/Swift/_parsed/Swift_Newsletter.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_cace62a36e7a414e9d28e7a8b3a8aad9.Execute() in C:\Projects\Solutions\mountainbikemuseum.net\Files\Templates\Designs\Swift\_parsed\Swift_Newsletter.parsed.cshtml:line 66
   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 2 @using Page = Dynamicweb.Content.Page 3 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4 @functions 5 { 6 private Page GetBrandingPage() 7 { 8 int brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 9 return brandingPageId > 0 ? Dynamicweb.Services.Pages?.GetPage(brandingPageId) : null; 10 } 11 12 private string GetFontsToLink() 13 { 14 Page brandingPage = GetBrandingPage(); 15 if (brandingPage == null) return ""; 16 17 List<string> fonts = new List<string>(); 18 AddFontFamily(brandingPage, "HeaderFont", fonts); 19 AddFontFamily(brandingPage, "DisplayFont", fonts); 20 AddFontFamily(brandingPage, "BodyFont", fonts); 21 22 var fontsToLink = string.Join("%7C", fonts.Where(x => !string.IsNullOrEmpty(x)).Distinct().Select(x => string.Format("{0}:100,200,300,400,500,600,700,800,900", x))); 23 return fontsToLink; 24 } 25 26 private static void AddFontFamily(Page brandingPage, string systemName, List<string> fonts) 27 { 28 if (brandingPage.Item[systemName] == null) return; 29 dynamic font = Newtonsoft.Json.JsonConvert.DeserializeObject(brandingPage.Item[systemName].ToString()); 30 if (font != null && font.Family != null) { 31 fonts.Add(font.Family.ToString()); 32 } 33 } 34 35 private string GetFontStyle(string type) 36 { 37 Page brandingPage = GetBrandingPage(); 38 if (brandingPage == null) return ""; 39 40 string fontStyle = ""; 41 dynamic font = Newtonsoft.Json.JsonConvert.DeserializeObject(brandingPage.Item[type+"Font"].ToString()); 42 if (font != null) { 43 fontStyle += $"font-family:{font.Family}, sans-serif;"; 44 fontStyle += $"font-weight:{font.SelectedVariant};"; 45 } 46 fontStyle += $"text-transform:{brandingPage.Item[type+"Casing"]};"; 47 fontStyle += $"line-height:{brandingPage.Item[type+"LineHeight"]};"; 48 fontStyle += $"letter-spacing:{brandingPage.Item[type+"LetterSpacing"]};"; 49 return fontStyle; 50 } 51 } 52 53 @{ 54 int newsletterWidth = Model.Item.GetInt32("Width"); 55 string mediaQuery = newsletterWidth + 20 + "px"; 56 string oneColWidth = newsletterWidth + "px"; 57 string twoColWidth = newsletterWidth / 2 + "px"; 58 string twoColGutterWidth = (newsletterWidth - 20) / 2 + "px"; 59 string backgroundColor = "#FFFFFF"; 60 string viewInBrowserLink = "/Default.aspx?ID=" + Model.ID; 61 string viewInBrowserText = Model.Item.GetString("ViewInBrowserText"); 62 string lang = Pageview.Area.CultureInfo.TwoLetterISOLanguageName; 63 string emailLinksColor = "#808080"; 64 string fontsToLink = GetFontsToLink(); 65 string bodyFontStyle = GetFontStyle("Body"); 66 string theme = !string.IsNullOrEmpty(Pageview.Page.PropertyItem["Theme"]?.ToString()) ? Pageview.Page.PropertyItem["Theme"].ToString().ToLower() : ""; 67 68 if (!string.IsNullOrEmpty(theme) && theme != "theme default") 69 { 70 var themesPageId = Pageview.AreaSettings.GetLink("ThemesPage") != null ? Pageview.AreaSettings.GetLink("ThemesPage").PageId : 0; 71 if (themesPageId > 0) 72 { 73 List<Paragraph> themesPageParagraphs = Dynamicweb.Services.Paragraphs.GetParagraphsByPageId(themesPageId)?.ToList(); 74 Paragraph themeParagraph = themesPageParagraphs?.FirstOrDefault(p => p.Item["Name"].ToString().ToLower().Equals(theme)); 75 76 if (themeParagraph != null) 77 { 78 backgroundColor = themeParagraph.Item["BackgroundColor"] != null ? themeParagraph.Item["BackgroundColor"].ToString() : ""; 79 backgroundColor = backgroundColor == "" ? "transparent" : backgroundColor; 80 } 81 } 82 } 83 } 84 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 85 <!--[if IE]> 86 <html xmlns="http://www.w3.org/1999/xhtml" class="ie" lang="@lang"> 87 <![endif]--> 88 <!--[if !IE]><!--> 89 <html style="margin: 0;padding: 0;" xmlns="http://www.w3.org/1999/xhtml" lang="@lang"> 90 <!--<![endif]--> 91 <head> 92 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 93 <title></title> 94 <!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--> 95 <meta name="viewport" content="width=device-width"> 96 <style type="text/css"> 97 @@media only screen and (min-width: @mediaQuery){.wrapper{min-width:@oneColWidth !important}.wrapper h1{}.wrapper h1{font-size:22px !important;line-height:31px !important}.wrapper h2{}.wrapper h2{font-size:20px !important;line-height:28px !important}.wrapper h3{}.wrapper h3{font-size:18px !important;line-height:26px !important}.column{}.wrapper .size-8{font-size:8px !important;line-height:14px !important}.wrapper .size-9{font-size:9px !important;line-height:16px !important}.wrapper .size-10{font-size:10px !important;line-height:18px !important}.wrapper .size-11{font-size:11px !important;line-height:19px !important}.wrapper .size-12{font-size:12px !important;line-height:19px !important}.wrapper .size-13{font-size:13px !important;line-height:21px !important}.wrapper .size-14{font-size:14px !important;line-height:21px !important}.wrapper .size-15{font-size:15px !important;line-height:23px 98 !important}.wrapper .size-16{font-size:16px !important;line-height:24px !important}.wrapper .size-17{font-size:17px !important;line-height:26px !important}.wrapper .size-18{font-size:18px !important;line-height:26px !important}.wrapper .size-20{font-size:20px !important;line-height:28px !important}.wrapper .size-22{font-size:22px !important;line-height:31px !important}.wrapper .size-24{font-size:24px !important;line-height:32px !important}.wrapper .size-26{font-size:26px !important;line-height:34px !important}.wrapper .size-28{font-size:28px !important;line-height:36px !important}.wrapper .size-30{font-size:30px !important;line-height:38px !important}.wrapper .size-32{font-size:32px !important;line-height:40px !important}.wrapper .size-34{font-size:34px !important;line-height:43px !important}.wrapper .size-36{font-size:36px !important;line-height:43px !important}.wrapper 99 .size-40{font-size:40px !important;line-height:47px !important}.wrapper .size-44{font-size:44px !important;line-height:50px !important}.wrapper .size-48{font-size:48px !important;line-height:54px !important}.wrapper .size-56{font-size:56px !important;line-height:60px !important}.wrapper .size-64{font-size:64px !important;line-height:63px !important}} 100 </style> 101 <meta name="x-apple-disable-message-reformatting"> 102 <style type="text/css"> 103 .main, .mso { 104 margin: 0; 105 padding: 0; 106 } 107 table { 108 border-collapse: collapse; 109 table-layout: fixed; 110 } 111 * { 112 line-height: inherit; 113 } 114 [x-apple-data-detectors] { 115 color: inherit !important; 116 text-decoration: none !important; 117 } 118 .wrapper .footer__share-button a:hover, 119 .wrapper .footer__share-button a:focus { 120 color: #ffffff !important; 121 } 122 .btn a:hover, 123 .btn a:focus, 124 .footer__share-button a:hover, 125 .footer__share-button a:focus, 126 .email-footer__links a:hover, 127 .email-footer__links a:focus { 128 opacity: 0.8; 129 } 130 .preheader, 131 .header, 132 .layout, 133 .column { 134 transition: width 0.25s ease-in-out, max-width 0.25s ease-in-out; 135 } 136 .preheader td { 137 padding-bottom: 8px; 138 } 139 .layout, 140 div.header { 141 max-width: 400px !important; 142 -fallback-width: 95% !important; 143 width: calc(100% - 20px) !important; 144 } 145 div.preheader { 146 max-width: 360px !important; 147 -fallback-width: 90% !important; 148 width: calc(100% - 60px) !important; 149 } 150 .snippet, 151 .webversion { 152 Float: none !important; 153 } 154 .stack .column { 155 max-width: 400px !important; 156 width: 100% !important; 157 } 158 .snippet, 159 .webversion { 160 width: 50% !important; 161 } 162 .ie .btn { 163 width: 100%; 164 } 165 .ie .stack .column, 166 .ie .stack .gutter { 167 display: table-cell; 168 height: 0; 169 float: none !important; 170 } 171 .ie div.preheader, 172 .ie .email-footer { 173 max-width: 560px !important; 174 width: 560px !important; 175 } 176 .ie .snippet, 177 .ie .webversion { 178 width: 280px !important; 179 } 180 .ie div.header, 181 .ie .layout { 182 max-width: @oneColWidth !important; 183 min-width: @oneColWidth !important; 184 width: @oneColWidth !important; 185 } 186 .ie .two-col .column { 187 max-width: @twoColWidth !important; 188 min-width: @twoColWidth !important; 189 width: @twoColWidth !important; 190 } 191 .ie .stack.two-col.has-gutter .column { 192 max-width: @twoColGutterWidth !important; 193 min-width: @twoColGutterWidth !important; 194 width: @twoColGutterWidth !important; 195 } 196 .ie .fixed-width .layout__inner { 197 border-left: 0 none white !important; 198 border-right: 0 none white !important; 199 } 200 .ie .layout__edges { 201 display: none; 202 } 203 .mso .layout__edges { 204 font-size: 0; 205 } 206 .layout-fixed-width, 207 .mso .layout-full-width { 208 background-color: @backgroundColor; 209 } 210 @@media only screen and (min-width: @mediaQuery) { 211 .column, 212 .gutter { 213 display: table-cell; 214 height: 0; 215 Float: none !important; 216 vertical-align: top; 217 } 218 div.preheader, 219 .email-footer { 220 max-width: 560px !important; 221 width: 560px !important; 222 } 223 .snippet, 224 .webversion { 225 width: 280px !important; 226 } 227 div.header, 228 .layout, 229 .one-col .column { 230 max-width: @oneColWidth !important; 231 min-width: @oneColWidth !important; 232 width: @oneColWidth !important; 233 } 234 .two-col .column { 235 max-width: @twoColWidth !important; 236 min-width: @twoColWidth !important; 237 width: @twoColWidth !important; 238 } 239 .two-col.has-gutter .column, 240 .two-col.x_has-gutter .column { 241 max-width: @twoColGutterWidth !important; 242 min-width: @twoColGutterWidth !important; 243 width: @twoColGutterWidth !important; 244 } 245 246 /*Style need for Comcast email to work. Doesn't seem to break any of the other providers*/ 247 .one-col .product-column.column { 248 width: @twoColGutterWidth !important; 249 } 250 251 .two-col .product-column.column, 252 .two-col .product-column.x_column, 253 .product-column.column, 254 .product-column.x_column { 255 min-width: 0 !important; 256 min-width: auto !important; 257 } 258 } 259 @@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { 260 .fblike { 261 background-image: url(/Files/EmailIcons/Facebook.png) !important; 262 } 263 .tweet { 264 background-image: url(/Files/EmailIcons/Twitter.png) !important; 265 } 266 .linkedinshare { 267 background-image: url(/Files/EmailIcons/Linkedin.png) !important; 268 } 269 .forwardtoafriend { 270 background-image: url(/Files/EmailIcons/Envelope.png) !important; 271 } 272 } 273 @@media (max-width: 321px) { 274 .layout, 275 .stack .column { 276 min-width: 320px !important; 277 width: 320px !important; 278 } 279 .border { 280 display: none; 281 } 282 .has-gutter .border { 283 display: table-cell; 284 } 285 } 286 .mso div { 287 border: 0 none white !important; 288 } 289 .mso .w560 .divider { 290 Margin-left: 260px !important; 291 Margin-right: 260px !important; 292 } 293 .mso .w360 .divider { 294 Margin-left: 160px !important; 295 Margin-right: 160px !important; 296 } 297 .mso .w260 .divider { 298 Margin-left: 110px !important; 299 Margin-right: 110px !important; 300 } 301 .mso .w160 .divider { 302 Margin-left: 60px !important; 303 Margin-right: 60px !important; 304 } 305 .mso .w354 .divider { 306 Margin-left: 157px !important; 307 Margin-right: 157px !important; 308 } 309 .mso .w250 .divider { 310 Margin-left: 105px !important; 311 Margin-right: 105px !important; 312 } 313 .mso .w148 .divider { 314 Margin-left: 54px !important; 315 Margin-right: 54px !important; 316 } 317 .mso .size-8, 318 .ie .size-8 { 319 font-size: 8px !important; 320 line-height: 14px !important; 321 } 322 .mso .size-9, 323 .ie .size-9 { 324 font-size: 9px !important; 325 line-height: 16px !important; 326 } 327 .mso .size-10, 328 .ie .size-10 { 329 font-size: 10px !important; 330 line-height: 18px !important; 331 } 332 .mso .size-11, 333 .ie .size-11 { 334 font-size: 11px !important; 335 line-height: 19px !important; 336 } 337 .mso .size-12, 338 .ie .size-12 { 339 font-size: 12px !important; 340 line-height: 19px !important; 341 } 342 .mso .size-13, 343 .ie .size-13 { 344 font-size: 13px !important; 345 line-height: 21px !important; 346 } 347 .mso .size-14, 348 .ie .size-14 { 349 font-size: 14px !important; 350 line-height: 21px !important; 351 } 352 .mso .size-15, 353 .ie .size-15 { 354 font-size: 15px !important; 355 line-height: 23px !important; 356 } 357 .mso .size-16, 358 .ie .size-16 { 359 font-size: 16px !important; 360 line-height: 24px !important; 361 } 362 .mso .size-17, 363 .ie .size-17 { 364 font-size: 17px !important; 365 line-height: 26px !important; 366 } 367 .mso .size-18, 368 .ie .size-18 { 369 font-size: 18px !important; 370 line-height: 26px !important; 371 } 372 .mso .size-20, 373 .ie .size-20 { 374 font-size: 20px !important; 375 line-height: 28px !important; 376 } 377 .mso .size-22, 378 .ie .size-22 { 379 font-size: 22px !important; 380 line-height: 31px !important; 381 } 382 .mso .size-24, 383 .ie .size-24 { 384 font-size: 24px !important; 385 line-height: 32px !important; 386 } 387 .mso .size-26, 388 .ie .size-26 { 389 font-size: 26px !important; 390 line-height: 34px !important; 391 } 392 .mso .size-28, 393 .ie .size-28 { 394 font-size: 28px !important; 395 line-height: 36px !important; 396 } 397 .mso .size-30, 398 .ie .size-30 { 399 font-size: 30px !important; 400 line-height: 38px !important; 401 } 402 .mso .size-32, 403 .ie .size-32 { 404 font-size: 32px !important; 405 line-height: 40px !important; 406 } 407 .mso .size-34, 408 .ie .size-34 { 409 font-size: 34px !important; 410 line-height: 43px !important; 411 } 412 .mso .size-36, 413 .ie .size-36 { 414 font-size: 36px !important; 415 line-height: 43px !important; 416 } 417 .mso .size-40, 418 .ie .size-40 { 419 font-size: 40px !important; 420 line-height: 47px !important; 421 } 422 .mso .size-44, 423 .ie .size-44 { 424 font-size: 44px !important; 425 line-height: 50px !important; 426 } 427 .mso .size-48, 428 .ie .size-48 { 429 font-size: 48px !important; 430 line-height: 54px !important; 431 } 432 .mso .size-56, 433 .ie .size-56 { 434 font-size: 56px !important; 435 line-height: 60px !important; 436 } 437 .mso .size-64, 438 .ie .size-64 { 439 font-size: 64px !important; 440 line-height: 63px !important; 441 } 442 443 .mt-0 > *:first-child { 444 margin-top: 0; 445 } 446 447 .mb-0 > *:last-child { 448 margin-bottom: 0; 449 } 450 </style> 451 <!--[if !mso]><!--> 452 <style type="text/css"> 453 @@import url(https://fonts.googleapis.com/css?family=@fontsToLink); 454 </style> 455 <link href="https://fonts.googleapis.com/css?family=@fontsToLink" rel="stylesheet" type="text/css"> 456 <!--<![endif]--> 457 <style type="text/css"> 458 .main,.mso{background-color:@backgroundColor}.logo a:hover,.logo a:focus{color:#1e2e3b !important}.mso h1,.ie h1{}.mso h1,.ie h1{font-size:22px !important;line-height:31px !important}.mso h2,.ie h2{}.mso h2,.ie h2{font-size:20px !important;line-height:28px !important}.mso h3,.ie h3{}.mso h3,.ie h3{font-size:18px !important;line-height:26px !important}.mso .layout__inner,.ie .layout__inner{}.mso .footer__share-button p{} 459 </style> 460 <meta name="robots" content="noindex,nofollow"></meta> 461 <meta property="og:title" content="@Model.Item.GetString("Title")"></meta> 462 </head> 463 <!--[if mso]> 464 <body class="mso"> 465 <![endif]--> 466 <!--[if !mso]><!--> 467 <body class="main no-padding" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;"> 468 <!--<![endif]--> 469 <table class="wrapper" style="background-color:@backgroundColor;border-collapse: collapse;table-layout: fixed;min-width: 320px;width: 100%;" cellpadding="0" cellspacing="0" role="presentation"> 470 <tbody> 471 <tr> 472 <td> 473 @if (!string.IsNullOrEmpty(viewInBrowserText)) 474 { 475 <div> 476 <div class="preheader" style="Margin: 0 auto;max-width: 560px;min-width: 280px; width: 280px;width: calc(28000% - 167440px);"> 477 <div style="border-collapse: collapse;display: table;width: 100%;"> 478 <!--[if (mso)|(IE)]><table align="center" class="preheader" cellpadding="0" cellspacing="0" role="presentation"><tr><td style="width: @oneColWidth" valign="top"><![endif]--> 479 <div class="webversion" style="display: table-cell;Float: left;font-size: 12px;max-width: @oneColWidth;min-width: 320px; width: 320px;width: calc(28000% - 167400px);padding: 10px 0 5px 0;text-align: center;color: @emailLinksColor;@bodyFontStyle"> 480 <p style="Margin-top: 0;Margin-bottom: 0;"> 481 <a style="text-decoration: underline;transition: opacity 0.1s ease-in;color: @emailLinksColor;" href=@viewInBrowserLink>@viewInBrowserText</a> 482 </p> 483 </div> 484 <!--[if (mso)|(IE)]></td></tr></table><![endif]--> 485 </div> 486 </div> 487 </div> 488 } 489 <div> 490 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 491 492 493 @Model.Grid("Grid", "Email Grid", "default:true;sort:1", "EmailPages") 494 495 </div> 496 <div role="contentinfo"> 497 <div class="layout one-col email-footer" style="Margin: 0 auto;max-width: @oneColWidth;min-width: 320px; width: 320px;width: calc(28000% - 167400px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;"> 498 <div class="layout__inner" style="border-collapse: collapse;display: table;width: 100%;"> 499 <!--[if (mso)|(IE)]><table align="center" cellpadding="0" cellspacing="0" role="presentation"><tr class="layout-email-footer"><td style="width: @oneColWidth;" class="w560"><![endif]--> 500 <div class="column" style="text-align: center;font-size: 12px;color: @emailLinksColor;@bodyFontStyle"> 501 <div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 10px;Margin-bottom: 10px;"> 502 <div style="font-size: 12px;line-height: 19px;margin-bottom: 15px;"> 503 <a style="text-decoration: underline;transition: opacity 0.1s ease-in;color: @emailLinksColor;" href="{{EmailMarketing:Email.UnsubscribeLink.Clean}}">@Translate("Unsubscribe")</a> 504 </div> 505 </div> 506 </div> 507 <!--[if (mso)|(IE)]></td></tr></table><![endif]--> 508 </div> 509 </div> 510 </div> 511 </td> 512 </tr> 513 </tbody> 514 </table> 515 </body> 516 </html> 517