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