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