Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_4b09f04ab2a04dd4a444493f36d5b399.Execute() in D:\dynamicweb.net\Solutions\twodayco3\OttoSch.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 238
   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 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 2 @using System 3 @using Dynamicweb 4 @using Dynamicweb.Environment 5 @using Dynamicweb.Frontend 6 @using System.Web 7 8 @{ 9 bool isVisualEdit = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 10 11 bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase); 12 bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet; 13 string responsiveHeaderClassDesktop = string.Empty; 14 string responsiveHeaderClassMobile = string.Empty; 15 if (renderAsResponsive) 16 { 17 responsiveHeaderClassDesktop = " d-none d-xl-block"; 18 responsiveHeaderClassMobile = " d-block d-xl-none"; 19 20 } 21 22 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 23 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0; 24 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty; 25 26 var brandingPage = Dynamicweb.Services.Pages?.GetPage(brandingPageId) ?? null; 27 var themesParagraphLastChanged = Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault(); 28 29 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt; 30 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"~/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css")); 31 32 // Schema.org details for PDP 33 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 34 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 35 string productDetailPageSchemaOrg = isProductDetailsPage ? "itemscope=\"\" itemtype=\"https://schema.org/Product\"" : ""; 36 37 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt) 38 { 39 //Branding page has been saved or the file is missing. Rewrite the file to disc. 40 if (brandingPageId > 0) 41 { 42 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId); 43 brandingPageview.Redirect = false; 44 brandingPageview.Output(); 45 } 46 } 47 48 49 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt) 50 { 51 //Branding page has been saved or the file is missing. Rewrite the file to disc. 52 if (themePageId > 0) 53 { 54 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId); 55 themePageview.Redirect = false; 56 themePageview.Output(); 57 } 58 } 59 60 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/css/styles.css")); 61 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/js/scripts.js")); 62 63 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 64 65 string headerCssClass = "sticky-top"; 66 bool movePageBehind = false; 67 string scrollInitScript = "swift.Scroll.init(); AOS.init({offset: 240});"; 68 if (Pageview.Page.PropertyItem != null) 69 { 70 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 71 movePageBehind = headerCssClass == "fixed-top" && !isVisualEdit ? true : false; 72 } 73 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 74 headerCssClass = isVisualEdit ? "" : headerCssClass; 75 76 string googleTagManagerId = Model.Area.Item.GetString("GoogleTagManagerID"); 77 78 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;"); 79 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css?{cssLastModified.Ticks}; rel=preload; as=style;"); 80 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/plyr.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 81 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/tiny-slider.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 82 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 83 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/flatpickr.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 84 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 85 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster 86 87 SetMetaTags(); 88 89 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 90 91 if (Pageview.Area.IsMaster) { 92 languages.Add(Pageview.Page); 93 if (Pageview.Page.Languages != null) { 94 foreach (var language in Pageview.Page.Languages) { 95 languages.Add(language); 96 } 97 } 98 } else { 99 languages.Add(Pageview.Page.MasterPage); 100 if (Pageview.Page.MasterPage != null) { 101 if (Pageview.Page.MasterPage.Languages != null) { 102 foreach (var language in Pageview.Page.MasterPage.Languages) { 103 languages.Add(language); 104 } 105 } 106 } 107 } 108 109 string siteLanguage = Pageview.Area.CultureInfo.Name; 110 Uri url = Dynamicweb.Context.Current.Request.Url; 111 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 112 113 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries(); 114 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies(); 115 var firstPage = Dynamicweb.Services.Pages.GetFirstPageForArea(Pageview.AreaID); 116 } 117 <!doctype html> 118 @{ 119 string cultureInfo = Pageview.Area.CultureInfo.TwoLetterISOLanguageName; 120 } 121 122 <html lang="@cultureInfo" id="@(firstPage != null && firstPage.ID == Pageview.ID ? "frontpage" : "")"> 123 <head> 124 <script id="CookieConsent" src="https://policy.app.cookieinformation.com/uc.js" data-culture="@cultureInfo" type="text/javascript"></script> 125 <!-- Google Tag Manager --> 126 <script> 127 (function (w, d, s, l, i) { 128 w[l] = w[l] || []; w[l].push({ 129 'gtm.start': 130 new Date().getTime(), event: 'gtm.js' 131 }); var f = d.getElementsByTagName(s)[0], 132 j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 133 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); 134 })(window, document, 'script', 'dataLayer', '@googleTagManagerId');</script> 135 <!-- End Google Tag Manager --> 136 137 @* Required meta tags *@ 138 <meta charset="utf-8"> 139 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0"> 140 <link rel="preconnect" href="https://fonts.gstatic.com" /> 141 142 <link rel="shortcut icon" href="~/Files/Templates/Designs/Swift/Assets/Images/favicon.png"> 143 <link rel="apple-touch-icon" href="~/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png"> 144 145 @Model.MetaTags 146 147 @{ 148 @* Languages meta data *@ 149 foreach (var language in languages) 150 { 151 if (language != null) 152 { 153 if (!string.IsNullOrEmpty(language.Area.DomainLock)) 154 { 155 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk 156 } 157 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(language.ID); 158 string href = $"{url.Scheme}://{hostName}{friendlyUrl}"; 159 160 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href" /> 161 } 162 } 163 } 164 165 <title>@Model.Title</title> 166 @* Bootstrap + Swift stylesheet *@ 167 <link href="~/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css"> 168 @* Branding and Themes min stylesheet *@ 169 <link href="~/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_@(Model.Area.ID).min.css?@cssLastModified.Ticks" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified"> 170 <script src="~/Files/Templates/Designs/Swift/Assets/js/tiny-slider.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 171 <script src="~/Files/Templates/Designs/Swift/Assets/js/plyr.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 172 <script src="~/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 173 <script src="~/Files/Templates/Designs/Swift/Assets/js/flatpickr.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 174 <script src="~/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 175 176 @if (!string.IsNullOrWhiteSpace(customHeaderInclude)) 177 { 178 @RenderPartial($"Components/Custom/{customHeaderInclude}") 179 } 180 </head> 181 <body class="brand @(masterTheme)" id="page@(Model.ID)" onload="@scrollInitScript"> 182 <!-- Google Tag Manager (noscript) --> 183 <noscript> 184 @{ string noScriptGTMURL = "https://www.googletagmanager.com/ns.html?id=" + googleTagManagerId; } 185 <iframe src="@noScriptGTMURL" 186 height="0" width="0" style="display:none;visibility:hidden"></iframe> 187 </noscript> 188 <!-- End Google Tag Manager (noscript) --> 189 190 @if (renderAsResponsive || !renderMobile) 191 { 192 <header class="page-header @headerCssClass top-0@(responsiveHeaderClassDesktop)" id="page-header-desktop"> 193 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null) 194 { 195 @RenderImpersonationBar() 196 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId) 197 } 198 </header> 199 } 200 201 @if ((renderAsResponsive || renderMobile)) 202 { 203 <header class="page-header @headerCssClass top-0@(responsiveHeaderClassMobile)" id="page-header-mobile"> 204 @if (@Model.Area.Item.GetLink("HeaderMobile") != null) 205 { 206 @RenderImpersonationBar() 207 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId) 208 } 209 </header> 210 } 211 212 <main id="content" class="mt-2" @productDetailPageSchemaOrg> 213 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 214 @using System 215 @using Dynamicweb.Ecommerce.ProductCatalog 216 217 @{ 218 string theme = ""; 219 string gridContent = ""; 220 221 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty; 222 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop"; 223 224 if (Model.PropertyItem != null) 225 { 226 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? " theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 227 } 228 229 if (Model.Item != null || Pageview.IsVisualEditorMode) 230 { 231 if (!isProductDetail) 232 { 233 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page"); 234 } 235 else 236 { 237 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId); 238 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty; 239 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage"); 240 @RenderGrid(detailPageId) 241 } 242 } 243 244 bool doNotRenderPage = false; 245 246 //Check if we are on the poduct detail page, and if there is data to render 247 ProductViewModel product = new ProductViewModel(); 248 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 249 { 250 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 251 if (string.IsNullOrEmpty(product.Id)) { 252 doNotRenderPage = true; 253 } 254 } 255 256 //Render the page 257 if (!doNotRenderPage) { 258 if (theme != "") 259 { 260 <div class="@theme"> 261 @gridContent 262 </div> 263 } 264 else 265 { 266 @gridContent 267 } 268 } else { 269 <div class="container"> 270 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div> 271 </div> 272 } 273 274 if (!Model.IsCurrentUserAllowed) 275 { 276 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 277 int signInPage = GetPageIdByNavigationTag("SignInPage"); 278 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage"); 279 280 if (!isVisualEditor) 281 { 282 if (signInPage != 0) 283 { 284 if (signInPage != Model.ID) { 285 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage); 286 } else { 287 if (dashboardPage != 0) { 288 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage); 289 } else { 290 Dynamicweb.Context.Current.Response.Redirect("/"); 291 } 292 } 293 } 294 else 295 { 296 <div class="alert alert-dark m-0" role="alert"> 297 <span>@Translate("You do not have access to this page")</span> 298 </div> 299 } 300 } 301 else 302 { 303 <div class="alert alert-dark m-0" role="alert"> 304 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span> 305 </div> 306 } 307 } 308 } 309 310 </main> 311 312 @if (renderAsResponsive || !renderMobile) 313 { 314 <footer class="page-footer d-none d-lg-block" id="page-footer-desktop"> 315 @if (@Model.Area.Item.GetLink("FooterDesktop") != null) 316 { 317 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId) 318 } 319 </footer> 320 } 321 322 @if (renderAsResponsive || renderMobile) 323 { 324 <footer class="page-footer d-block d-lg-none" id="page-footer-mobile"> 325 @if (@Model.Area.Item.GetLink("FooterMobile") != null) 326 { 327 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId) 328 } 329 </footer> 330 } 331 332 @* Render any offcanvas menu here *@ 333 @RenderSnippet("offcanvas") 334 335 @* Language selector modal *@ 336 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1) 337 { 338 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true"> 339 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent"> 340 @* The content here comes from an external request *@ 341 </div> 342 </div> 343 } 344 345 @* Offcanvas for dynamic content *@ 346 <div class="offcanvas offcanvas-end" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem"> 347 @* The content here comes from an external request *@ 348 </div> 349 </body> 350 </html> 351 @functions { 352 353 void SetMetaTags() 354 { 355 //Verification Tokens 356 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : ""; 357 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : ""; 358 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : ""; 359 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : ""; 360 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : ""; 361 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : ""; 362 363 //Generic Site Values 364 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : ""; 365 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : ""; 366 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : ""; 367 368 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : ""; 369 370 //Page specific values 371 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : ""; 372 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image"); 373 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : ""; 374 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : ""; 375 376 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : ""; 377 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : ""; 378 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : ""; 379 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image"); 380 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : ""; 381 382 if (!string.IsNullOrEmpty(siteVerificationGoogle)) 383 { 384 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle); 385 } 386 387 if (!string.IsNullOrEmpty(openGraphFacebookAppID)) 388 { 389 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID); 390 } 391 392 if (!string.IsNullOrEmpty(openGraphType)) 393 { 394 Pageview.Meta.AddTag("og:type", openGraphType); 395 } 396 397 if (!string.IsNullOrEmpty(openGraphSiteName)) 398 { 399 Pageview.Meta.AddTag("og:site_name", openGraphSiteName); 400 } 401 402 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]) && !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"])) 403 { 404 if (!string.IsNullOrEmpty(Model.Title)) 405 { 406 Pageview.Meta.AddTag("og:title", Model.Title); 407 } 408 else 409 { 410 Pageview.Meta.AddTag("og:title", openGraphSiteTitle); 411 } 412 if (!string.IsNullOrEmpty(Model.Description)) 413 { 414 Pageview.Meta.AddTag("og:description", Model.Description); 415 } 416 else 417 { 418 Pageview.Meta.AddTag("og:description", openGraphDescription); 419 } 420 } 421 422 if (openGraphImage != null) 423 { 424 Pageview.Meta.AddTag("og:image", openGraphImage.Path); 425 } 426 427 if (!string.IsNullOrEmpty(openGraphImageALT)) 428 { 429 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT); 430 } 431 432 if (!string.IsNullOrEmpty(twitterCardSite)) 433 { 434 Pageview.Meta.AddTag("twitter:site", twitterCardSite); 435 } 436 437 if (!string.IsNullOrEmpty(twitterCardURL)) 438 { 439 Pageview.Meta.AddTag("twitter:url", twitterCardURL); 440 } 441 442 if (!string.IsNullOrEmpty(twitterCardTitle)) 443 { 444 Pageview.Meta.AddTag("twitter:title", twitterCardTitle); 445 } 446 447 if (!string.IsNullOrEmpty(twitterCardDescription)) 448 { 449 Pageview.Meta.AddTag("twitter:description", twitterCardDescription); 450 } 451 452 if (twitterCardImage != null) 453 { 454 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path); 455 } 456 457 if (!string.IsNullOrEmpty(twitterCardImageALT)) 458 { 459 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT); 460 } 461 } 462 } 463 464 @helper RenderImpersonationBar() { 465 var user = Pageview.User; 466 467 if(user != null) 468 { 469 var secondaryUser = user.CurrentSecondaryUser; 470 var isImpersonating = secondaryUser != null && secondaryUser.ID > 0; 471 472 if(isImpersonating) 473 { 474 <div class="impersonation-bar d-flex justify-content-center align-items-center py-2 bg-light fs-8 flex-column flex-md-row"> 475 <p class="mb-0">@Translate("Logget ind som") <span class="fw-bold">@user.UserName</span></p> 476 <span class="px-2 d-none d-md-block">|</span> 477 <a href="Default.aspx?ID=@(Pageview.ID)&DwExtranetRemoveSecondaryUser=1" class="mb-0 text-decoration-none text-decoration-underline-hover">@Translate("Stop impersonering")</a> 478 </div> 479 } 480 } 481 } 482