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