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