Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Content.Layouts.LayoutTemplateLocator.FindLayoutTemplateForPage(Page page)
   at Dynamicweb.Frontend.Content.GetLayoutForDevice(Page page, DeviceType device)
   at Dynamicweb.Frontend.Content.CreateGridContent(Int32 contentId, Boolean ignoreVisualEdit)
   at Dynamicweb.Frontend.Content.RenderExternalGrid(Int32 pageId, String container)
   at CompiledRazorTemplates.Dynamic.RazorEngine_2907bbbea6344eb581178bcf520050bc.Execute() in D:\Solution\BKI LIVE\Files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 584
   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 S_DW_BKI_Swift.CustomModules.Helpers 7 @using S_DW_BKI_Swift.CustomModules.Extensions; 8 9 @{ 10 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt"); 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 responsiveClassDesktop = string.Empty; 14 string responsiveClassMobile = string.Empty; 15 if (renderAsResponsive) 16 { 17 responsiveClassDesktop = " d-none d-xl-block"; 18 responsiveClassMobile = " d-block d-xl-none"; 19 } 20 21 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default"); 22 23 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 24 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0; 25 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty; 26 27 var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null; 28 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault(); 29 30 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt; 31 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css")); 32 33 34 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 35 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 36 bool isArticlePage = Model.ItemType == "Swift_Article"; 37 Dynamicweb.Content.PageService ps = new Dynamicweb.Content.PageService(); 38 var page = ps.GetFirstPageForArea(Dynamicweb.Frontend.PageView.Current().AreaID); 39 40 41 bool isFrontpage = Dynamicweb.Frontend.PageView.Current().Page.ID == page.ID ? true : false; 42 var getSchemaParagraph = SchemaMarkupHelpers.GetParagraphById(Pageview, "ActivateSchema"); 43 bool activateOrgSchema = getSchemaParagraph != null ? Convert.ToBoolean(getSchemaParagraph.Item["ShowOrganizationShema"]) : false; 44 45 46 bool showOrgSchema = false; 47 var customSettings = SchemaMarkupHelpers.GetCustomSettings(Pageview); 48 49 bool useSchema = false; 50 if (customSettings != null) 51 { 52 useSchema = customSettings.Item["ShowSchema"] != null ? Convert.ToBoolean(customSettings.Item["ShowSchema"]) : false; 53 } 54 55 string schemaOrgType = string.Empty; 56 57 if (isProductDetailsPage) 58 { 59 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\""; 60 } 61 62 if (isArticlePage) 63 { 64 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\""; 65 } 66 67 if (isFrontpage) 68 { 69 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Organization\""; 70 } 71 72 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt) 73 { 74 //Branding page has been saved or the file is missing. Rewrite the file to disc. 75 if (brandingPageId > 0) 76 { 77 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId); 78 brandingPageview.Redirect = false; 79 brandingPageview.Output(); 80 } 81 } 82 83 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt) 84 { 85 //Branding page has been saved or the file is missing. Rewrite the file to disc. 86 if (themePageId > 0) 87 { 88 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId); 89 themePageview.Redirect = false; 90 themePageview.Output(); 91 } 92 } 93 94 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css")); 95 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js")); 96 97 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 98 99 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png"; 100 101 string headerCssClass = "sticky-top"; 102 bool movePageBehind = false; 103 104 if (Pageview.Page.PropertyItem != null) 105 { 106 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 107 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false; 108 } 109 110 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 111 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 112 113 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID"); 114 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID"); 115 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 116 bool allowTracking = true; 117 118 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;"); 119 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;"); 120 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 121 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 122 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster 123 124 SetMetaTags(); 125 126 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 127 128 if (Pageview.Area.IsMaster) 129 { 130 languages.Add(Pageview.Page); 131 if (Pageview.Page.Languages != null) 132 { 133 foreach (var language in Pageview.Page.Languages) 134 { 135 languages.Add(language); 136 } 137 } 138 } 139 else 140 { 141 languages.Add(Pageview.Page.MasterPage); 142 if (Pageview.Page.MasterPage != null) 143 { 144 if (Pageview.Page.MasterPage.Languages != null) 145 { 146 foreach (var language in Pageview.Page.MasterPage.Languages) 147 { 148 languages.Add(language); 149 } 150 } 151 } 152 } 153 154 string siteLanguage = Pageview.Area.CultureInfo.Name; 155 Uri url = Dynamicweb.Context.Current.Request.Url; 156 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 157 158 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries(); 159 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies(); 160 161 // CUSTOM ADD START 162 string customHeadScripts = CustomSettingsHelper.GetSetting<string>("CustomHeadScripts"); 163 string customBodyScripts = CustomSettingsHelper.GetSetting<string>("CustomBodyScripts"); 164 bool renderCustomHeadScripts = !string.IsNullOrEmpty(customHeadScripts); 165 bool renderCustomBodyScripts = !string.IsNullOrEmpty(customBodyScripts); 166 167 var currentPage = S_DW_BKI_Swift.CustomModules.Helpers.TemplateHelper.GetCurrentPage(); 168 var isBCRpage = S_DW_BKI_Swift.CustomModules.Helpers.TemplateHelper.IsBCRPage(currentPage); 169 // CUSTOM ADD END 170 } 171 <!doctype html> 172 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 173 <head> 174 <!-- @swiftVersion --> 175 @if (renderCustomHeadScripts) 176 { 177 @customHeadScripts 178 } 179 @* Required meta tags *@ 180 <meta charset="utf-8"> 181 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0"> 182 <link rel="shortcut icon" href="@favicon"> 183 @*custom edit start*@ 184 @if (isFrontpage && useSchema || activateOrgSchema && useSchema) 185 { 186 @SchemaMarkupHelpers.GetSchemaMarkupForOrganization(customSettings, Pageview) 187 } 188 189 @if (isArticlePage && useSchema) 190 { 191 @SchemaMarkupHelpers.GetSchemaMarkupForArticle(customSettings, Pageview) 192 193 } 194 195 @if (isProductDetailsPage && useSchema) 196 { 197 @SchemaMarkupHelpers.GetSchemaMarkupForProduct(customSettings, Pageview, productId) 198 } 199 200 @if (!string.IsNullOrEmpty(favicon)) 201 { 202 <link rel="apple-touch-icon" href="@favicon"> 203 } 204 205 @RenderSnippet("videoSchema") 206 @RenderSnippet("recipeSchema") 207 <link rel="canonical" href="@Pageview.GetCanonical()"> 208 209 @*custom edit end*@ 210 211 212 213 @*Add noindex nofollow on category pages but check first if added already*@ 214 215 @if (!Model.MetaTags.Contains("<meta name=\"robots\" content=\"noindex,nofollow\">")) 216 { 217 @RenderSnippet("robotsProductList") 218 @Model.MetaTags 219 220 221 } 222 else 223 { 224 @Model.MetaTags} 225 226 227 @{ 228 var alreadyWrittenTwoletterIsos = new List<string>(); 229 @* Languages meta data *@ 230 foreach (var language in languages) 231 { 232 hostName = url.Host; 233 if (language?.Area != null) 234 { 235 if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock)) 236 { 237 hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk 238 } 239 if (language != null && language.Published && language.Area.Active && language.Area.Published) 240 { 241 if (!string.IsNullOrEmpty(language.Area.DomainLock)) 242 { 243 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk 244 } 245 string querystring = $"Default.aspx?ID={language.ID}"; 246 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"])) 247 { 248 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}"; 249 } 250 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"])) 251 { 252 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}"; 253 } 254 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"])) 255 { 256 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}"; 257 } 258 259 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring); 260 if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1) 261 { 262 friendlyUrl = "/"; 263 } 264 string href = $"{url.Scheme}://{hostName}{friendlyUrl}"; 265 266 267 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href"> 268 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName)) 269 { 270 <link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href"> 271 } 272 } 273 } 274 } 275 } 276 277 <title>@Model.Title</title> 278 @* Bootstrap + Swift stylesheet *@ 279 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css"> 280 281 @if (disableWideBreakpoints != "disableBoth") 282 { 283 <style> 284 @@media ( min-width: 1600px ) { 285 .container-xxl, 286 .container-xl, 287 .container-lg, 288 .container-md, 289 .container-sm, 290 .container { 291 max-width: 1520px; 292 } 293 } 294 </style> 295 296 297 298 if (disableWideBreakpoints != "disableUltraWideOnly") 299 { 300 <style> 301 @@media ( min-width: 1920px ) { 302 .container-xxl, 303 .container-xl, 304 .container-lg, 305 .container-md, 306 .container-sm, 307 .container { 308 max-width: 1820px; 309 } 310 } 311 </style> 312 } 313 } 314 315 @* Branding and Themes min stylesheet *@ 316 <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"> 317 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 318 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 319 320 <script type="module"> 321 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') }); 322 swift.Scroll.hideHeadersOnScroll(); 323 swift.Scroll.handleAlternativeTheme(); 324 </script> 325 326 @* Google tag manager *@ 327 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking) 328 { 329 <script> 330 @if (!renderCustomHeadScripts) 331 { 332 <text> 333 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 334 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 335 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 336 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 337 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)'); 338 </text> 339 } 340 341 function gtag() { dataLayer.push(arguments); } 342 </script> 343 } 344 345 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 346 { 347 var GoogleAnalyticsDebugMode = ""; 348 bool isLoggedInBackendUser = false; 349 350 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null) 351 { 352 isLoggedInBackendUser = true; 353 } 354 355 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser) 356 { 357 GoogleAnalyticsDebugMode = ", {'debug_mode': true}"; 358 } 359 360 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script> 361 <script> 362 window.dataLayer = window.dataLayer || []; 363 function gtag() { dataLayer.push(arguments); } 364 gtag('js', new Date()); 365 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode); 366 </script> 367 } 368 369 @if (!string.IsNullOrWhiteSpace(customHeaderInclude) && !isBCRpage) 370 { 371 @RenderPartial($"Components/Custom/{customHeaderInclude}") 372 } 373 374 @if (isBCRpage) 375 { 376 <link rel="stylesheet" href=https://use.typekit.net/jbn6ewy.css> 377 <style> 378 main { 379 font-family: "tomarik-poster", sans-serif !important; 380 } 381 382 main h1, main h2, main h3, main h4, main h5, main h6, 383 main .h1, main .h2, main .h3, main .h4, main .h5, main .h6, 384 main .display-1, main .display-2, main .display-3, 385 main .display-4, main .display-5, main .display-6 { 386 font-family: "citrus-gothic-solid", sans-serif !important; 387 } 388 </style> 389 } 390 </head> 391 <body class="brand @(masterTheme)" id="page@(Model.ID)"> 392 @* CUSTOM EDIT START *@ 393 @if (renderCustomBodyScripts) 394 { 395 @customBodyScripts 396 } 397 else 398 { 399 @* Google tag manager *@ 400 if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking) 401 { 402 <noscript> 403 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)" 404 height="0" width="0" style="display:none;visibility:hidden"></iframe> 405 </noscript> 406 } 407 } 408 @* CUSTOM EDIT END *@ 409 410 @if (renderAsResponsive || !renderMobile) 411 { 412 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop"> 413 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null) 414 { 415 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId) 416 } 417 </header> 418 } 419 420 @if ((renderAsResponsive || renderMobile)) 421 { 422 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile"> 423 @if (@Model.Area.Item.GetLink("HeaderMobile") != null) 424 { 425 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId) 426 } 427 </header> 428 } 429 430 <main id="content" @(schemaOrgType)> 431 <div data-intersect></div> 432 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 433 @using System 434 @using Dynamicweb.Ecommerce.ProductCatalog 435 436 437 @{ 438 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty; 439 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && new[] { "shop", "shopanonymous" }.Contains(Pageview.Page.NavigationTag.ToLower()); // CUSTOM EDIT 440 441 bool isArticlePagePage = Model.ItemType == "Swift_Article"; 442 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage"; 443 string schemaOrgProp = string.Empty; 444 if(isArticlePagePage) 445 { 446 schemaOrgProp = "itemprop=\"articleBody\""; 447 } 448 449 string theme = ""; 450 string gridContent = ""; 451 452 if (Model.PropertyItem != null) 453 { 454 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 455 } 456 457 if (Model.Item != null || Pageview.IsVisualEditorMode) 458 { 459 if (!isProductDetail) 460 { 461 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page"); 462 } 463 else 464 { 465 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId); 466 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty; 467 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage"); 468 469 @RenderGrid(detailPageId) 470 } 471 } 472 473 bool doNotRenderPage = false; 474 475 //Check if we are on the poduct detail page, and if there is data to render 476 ProductViewModel product = new ProductViewModel(); 477 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 478 { 479 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 480 if (string.IsNullOrEmpty(product.Id)) { 481 doNotRenderPage = true; 482 } 483 } 484 485 //Render the page 486 if (!doNotRenderPage) { 487 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page"; 488 489 490 <div class="@theme @itemIdentifier" @schemaOrgProp> 491 @if (isArticleListPage) 492 { 493 var hx = $"hx-get=\"{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Model.ID)}\" hx-select=\"#content\" hx-target=\"#content\" hx-swap=\"outerHTML\" hx-trigger=\"change\" hx-headers='{{\"feed\": \"true\"}}' hx-push-url=\"true\" hx-indicator=\"#ArticleFacetForm\""; 494 495 <form @hx id="ArticleFacetForm"> 496 @gridContent 497 </form> 498 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script> 499 <script type="module"> 500 document.addEventListener('htmx:confirm', (event) => { 501 let filters = event.detail.elt.querySelectorAll('select'); 502 for (var i = 0; i < filters.length; i++) { 503 let input = filters[i]; 504 if (input.name && !input.value) { 505 input.name = ''; 506 } 507 } 508 }); 509 510 document.addEventListener('htmx:beforeOnLoad', (event) => { 511 swift.Scroll.stopIntersectionObserver(); 512 }); 513 514 document.addEventListener('htmx:afterOnLoad', () => { 515 swift.Scroll.hideHeadersOnScroll(); 516 swift.Scroll.handleAlternativeTheme(); 517 }); 518 </script> 519 } 520 else 521 { 522 @gridContent 523 } 524 </div> 525 526 } else { 527 <div class="container"> 528 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div> 529 </div> 530 } 531 532 if (!Model.IsCurrentUserAllowed) 533 { 534 int signInPage = GetPageIdByNavigationTag("SignInPage"); 535 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage"); 536 537 if (!Pageview.IsVisualEditorMode) 538 { 539 if (signInPage != 0) 540 { 541 if (signInPage != Model.ID) { 542 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage); 543 } else { 544 if (dashboardPage != 0) { 545 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage); 546 } else { 547 Dynamicweb.Context.Current.Response.Redirect("/"); 548 } 549 } 550 } 551 else 552 { 553 <div class="alert alert-dark m-0" role="alert"> 554 <span>@Translate("You do not have access to this page")</span> 555 </div> 556 } 557 } 558 else 559 { 560 <div class="alert alert-dark m-0" role="alert"> 561 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span> 562 </div> 563 } 564 } 565 } 566 567 </main> 568 569 @if (renderAsResponsive || !renderMobile) 570 { 571 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop"> 572 @if (@Model.Area.Item.GetLink("FooterDesktop") != null) 573 { 574 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId) 575 } 576 </footer> 577 } 578 579 @if (renderAsResponsive || renderMobile) 580 { 581 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile"> 582 @if (@Model.Area.Item.GetLink("FooterMobile") != null) 583 { 584 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId) 585 } 586 </footer> 587 } 588 589 @* Render any offcanvas menu here *@ 590 @RenderSnippet("offcanvas") 591 592 @{ 593 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]); 594 } 595 596 @* Language selector modal *@ 597 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1) 598 { 599 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true"> 600 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent"> 601 @* The content here comes from an external request *@ 602 </div> 603 </div> 604 } 605 606 @* Favorite toast *@ 607 <div aria-live="polite" aria-atomic="true"> 608 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11"> 609 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true"> 610 <div class="toast-header"> 611 <strong class="me-auto">@Translate("Favorite list updated")</strong> 612 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> 613 </div> 614 <div class="toast-body d-flex gap-3"> 615 <div id="favoriteNotificationToast_Image"></div> 616 <div id="favoriteNotificationToast_Text"></div> 617 </div> 618 </div> 619 </div> 620 </div> 621 622 @* Modal for dynamic content *@ 623 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true"> 624 <div class="modal-dialog modal-dialog-centered modal-md"> 625 <div class="modal-content theme light" id="DynamicModalContent"> 626 @* The content here comes from an external request *@ 627 </div> 628 </div> 629 </div> 630 631 @* Offcanvas for dynamic content *@ 632 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem"> 633 @* The content here comes from an external request *@ 634 </div> 635 636 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage")) 637 { 638 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light"; 639 640 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040"> 641 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true"> 642 <div class="toast-header"> 643 <strong class="me-auto">@Translate("Connection down")</strong> 644 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> 645 </div> 646 <div class="toast-body"> 647 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.") 648 </div> 649 </div> 650 </div> 651 } 652 </body> 653 </html> 654 @functions { 655 void SetMetaTags() 656 { 657 //Verification Tokens 658 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : ""; 659 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : ""; 660 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : ""; 661 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : ""; 662 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : ""; 663 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : ""; 664 665 //Generic Site Values 666 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : ""; 667 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : ""; 668 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : ""; 669 670 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : ""; 671 672 //Page specific values 673 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : ""; 674 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image"); 675 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : ""; 676 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : ""; 677 678 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : ""; 679 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : ""; 680 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : ""; 681 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image"); 682 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : ""; 683 684 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"])) 685 { 686 if (!string.IsNullOrEmpty(Model.Description)) 687 { 688 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\" />"); 689 } 690 else 691 { 692 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\" />"); 693 } 694 695 if (!string.IsNullOrEmpty(Pageview.Page.TopImage)) 696 { 697 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\" />"); 698 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\" />"); 699 } 700 else if (openGraphImage != null) 701 { 702 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />"); 703 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />"); 704 } 705 706 if (!string.IsNullOrEmpty(openGraphImageALT)) 707 { 708 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\"/>"); 709 } 710 if (!string.IsNullOrEmpty(twitterCardDescription)) 711 { 712 Pageview.Meta.AddTag("twitter:description", twitterCardDescription); 713 } 714 715 if (!string.IsNullOrEmpty(Pageview.Page.TopImage)) 716 { 717 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}"); 718 } 719 else if (twitterCardImage != null) 720 { 721 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}"); 722 } 723 724 if (!string.IsNullOrEmpty(twitterCardImageALT)) 725 { 726 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT); 727 } 728 } 729 730 if (!string.IsNullOrEmpty(siteVerificationGoogle)) 731 { 732 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle); 733 } 734 735 if (!string.IsNullOrEmpty(openGraphFacebookAppID)) 736 { 737 Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\" />"); 738 } 739 740 if (!string.IsNullOrEmpty(openGraphType)) 741 { 742 Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\" />"); 743 } 744 745 if (!string.IsNullOrEmpty(openGraphSiteName)) 746 { 747 Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\" />"); 748 } 749 750 if (!string.IsNullOrEmpty(openGraphSiteName)) 751 { 752 Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\" />"); 753 } 754 755 if (!string.IsNullOrEmpty(Model.Title)) 756 { 757 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\"/>"); 758 } 759 else 760 { 761 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\" />"); 762 } 763 764 if (!string.IsNullOrEmpty(twitterCardSite)) 765 { 766 Pageview.Meta.AddTag("twitter:site", twitterCardSite); 767 } 768 769 if (!string.IsNullOrEmpty(twitterCardURL)) 770 { 771 Pageview.Meta.AddTag("twitter:url", twitterCardURL); 772 } 773 774 if (!string.IsNullOrEmpty(twitterCardTitle)) 775 { 776 Pageview.Meta.AddTag("twitter:title", twitterCardTitle); 777 } 778 } 779 } 780