Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at CompiledRazorTemplates.Dynamic.RazorEngine_5b4b926334c54546995fb765b7c09942.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 332
   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 System.Web 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 responsiveHeaderClassDesktop = string.Empty; 13 string responsiveHeaderClassMobile = string.Empty; 14 if (renderAsResponsive) 15 { 16 responsiveHeaderClassDesktop = " d-none d-xl-block"; 17 responsiveHeaderClassMobile = " d-block d-xl-none"; 18 19 } 20 21 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 22 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0; 23 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty; 24 25 var brandingPage = Dynamicweb.Services.Pages?.GetPage(brandingPageId) ?? null; 26 var themesParagraphLastChanged = Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault(); 27 28 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt; 29 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"~/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css")); 30 31 // Schema.org details for PDP 32 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 33 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 34 string schema = Pageview.Page.NavigationTag == "Recipes" ? "Recipe" : "Product"; // Set specific schema for recipe-products pages 35 string productDetailPageSchemaOrg = isProductDetailsPage ? "itemscope=\"\" itemtype=\"https://schema.org/"+ schema + "\"" : ""; 36 37 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt) 38 { 39 //Branding page has been saved or the file is missing. Rewrite the file to disc. 40 if (brandingPageId > 0) 41 { 42 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId); 43 brandingPageview.Redirect = false; 44 brandingPageview.Output(); 45 } 46 } 47 48 49 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt) 50 { 51 //Branding page has been saved or the file is missing. Rewrite the file to disc. 52 if (themePageId > 0) 53 { 54 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId); 55 themePageview.Redirect = false; 56 themePageview.Output(); 57 } 58 } 59 60 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/css/styles.css")); 61 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/js/scripts.js")); 62 63 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 64 65 string headerCssClass = "sticky-top"; 66 bool movePageBehind = false; 67 string scrollInitScript = "swift.Scroll.init(); AOS.init({offset: 240, duration: 600, delay: 100}); disable: window.matchMedia('(prefers-reduced-motion: reduce)');"; 68 if (Pageview.Page.PropertyItem != null) 69 { 70 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 71 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false; 72 } 73 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 74 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 75 76 string googleAnalyticsTrackingID = Model.Area.Item.GetString("GoogleAnalyticsTrackingID"); 77 string etrackerDataSecureCode = Model.Area.Item.GetString("EtrakerDataSecureCode"); 78 bool allowCookies = CookieManager.GetCookieOptInLevel() == 0 || !CookieManager.CookieOptInLevelExists ? false : true; 79 string cookieDeclarationKey = Model.Area.Item.GetString("CookieDeclarationKey"); 80 81 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;"); 82 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;"); 83 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 84 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 85 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster 86 87 SetMetaTags(); 88 89 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 90 91 if (Pageview.Area.IsMaster) { 92 languages.Add(Pageview.Page); 93 if (Pageview.Page.Languages != null) { 94 foreach (var language in Pageview.Page.Languages) { 95 languages.Add(language); 96 } 97 } 98 } else { 99 languages.Add(Pageview.Page.MasterPage); 100 if (Pageview.Page.MasterPage != null) { 101 if (Pageview.Page.MasterPage.Languages != null) { 102 foreach (var language in Pageview.Page.MasterPage.Languages) { 103 languages.Add(language); 104 } 105 } 106 } 107 } 108 109 string siteLanguage = Pageview.Area.CultureInfo.Name; 110 Uri url = Dynamicweb.Context.Current.Request.Url; 111 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 112 113 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries(); 114 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies(); 115 } 116 <!doctype html> 117 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 118 <head> 119 <!-- @swiftVersion --> 120 @* Required meta tags *@ 121 <meta charset="utf-8"> 122 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0"> 123 <link rel="preconnect" href="https://fonts.gstatic.com" /> 124 125 <link rel="shortcut icon" href="~/Files/Templates/Designs/Swift/Assets/Images/favicon.png"> 126 <link rel="apple-touch-icon" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon.png"> 127 <link rel="apple-touch-icon" sizes="152x152" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon-152x152.png"> 128 <link rel="apple-touch-icon" sizes="180x180" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon-180x180.png"> 129 <link rel="apple-touch-icon" sizes="114x114" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon-114x114.png"> 130 <link rel="apple-touch-icon" sizes="120x120" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon-120x120.png"> 131 <link rel="apple-touch-icon" sizes="144x144" href="~/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon-144x144.png"> 132 133 134 @Model.MetaTags 135 136 @{ 137 @* Languages meta data *@ 138 foreach (var language in languages) 139 { 140 if (language != null) { 141 if (!string.IsNullOrEmpty(language.Area.DomainLock)) 142 { 143 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk 144 } 145 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(language.ID); 146 string href = $"{url.Scheme}://{hostName}{friendlyUrl}"; 147 148 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href" /> 149 } 150 } 151 } 152 153 <title>@Model.Title</title> 154 @* Bootstrap + Swift stylesheet *@ 155 <link href="~/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css"> 156 @* Branding and Themes min stylesheet *@ 157 <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"> 158 159 @* cookie Consent *@ 160 @if (!string.IsNullOrWhiteSpace(cookieDeclarationKey)) 161 { 162 <script> 163 (function (C, oo, k, ie, b, o, t) { 164 var a=C.scripts[0],d=C.createElement(ie),e=[/^\/([a-z]{2})([_-][a-z]{2})?(\/.*)?$/g. 165 exec(k),/^([a-z]{2})\./.exec(oo),/\.([a-z]{2,})$/.exec(oo)],f={au:"en",ca:"en",cz: 166 "cs",dk:"da",ee:"et",no:"nb",se:"sv",ie:"en",uk:"en"},g=0;for(g of e){e=g?g[1]:t;if(g)break} 167 e=e.length!=2?t:e;e=f[e]?f[e]:e;d.id=b;d.setAttribute("data-culture",e);d.src= 168 "https://consent.cookiebot.com/uc.js?cbid="+o;d.async=!0;a.parentNode.insertBefore( 169 d, a)})(document,location.hostname,location.pathname,"script","Cookiebot","@cookieDeclarationKey", "en") 170 </script> 171 } 172 173 <style type="text/css"> 174 a#CybotCookiebotDialogPoweredbyCybot, 175 div#CybotCookiebotDialogPoweredByText { 176 display: none; 177 } 178 179 #CookiebotWidget .CookiebotWidget-body .CookiebotWidget-main-logo { 180 display: none; 181 } 182 </style> 183 184 <script src="~/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 185 <script src="~/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 186 187 188 @* Global site tag (gtag.js) - Google Analytics *@ 189 @if (!string.IsNullOrWhiteSpace(googleAnalyticsTrackingID) && allowCookies) 190 { 191 <script src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsTrackingID" async></script> 192 <script>@googleAnalyticsTrackingID</script> 193 } 194 195 @* Etracker *@ 196 @if (!string.IsNullOrWhiteSpace(etrackerDataSecureCode)) 197 { 198 <!-- .SE --> 199 <!-- Copyright (c) 2000-2022 etracker GmbH. All rights reserved. --> 200 <!-- This material may not be reproduced, displayed, modified or distributed --> 201 <!-- without the express prior written permission of the copyright holder. --> 202 <!-- etracker tracklet 5.0 --> 203 <script type="text/javascript"> 204 // var et_pagename = ""; 205 // var et_areas = ""; 206 // var et_tval = 0; 207 // var et_tsale = 0; 208 // var et_tonr = ""; 209 // var et_basket = ""; 210 </script> 211 <script id="_etLoader" type="text/javascript" charset="UTF-8" data-block-cookies="true" data-respect-dnt="true" data-secure-code="@etrackerDataSecureCode" src="//code.etracker.com/code/e.js" async></script> 212 <!-- etracker tracklet 5.0 end --> 213 } 214 215 @if (!string.IsNullOrWhiteSpace(customHeaderInclude)) 216 { 217 @RenderPartial($"Components/Custom/{customHeaderInclude}") 218 } 219 220 @{ 221 // Set a body class based on Page.NavigationTag for targeted UX customizations 222 string bodyClass = Pageview.Page.NavigationTag; 223 if (!Dynamicweb.Context.Current.Items.Contains("ProductList")) 224 { 225 bodyClass = bodyClass + "Page"; 226 } 227 } 228 229 </head> 230 <body class="brand @(masterTheme) @bodyClass" id="page@(Model.ID)" onload="@scrollInitScript"> 231 @if (renderAsResponsive || !renderMobile) 232 { 233 <header class="page-header @headerCssClass top-0@(responsiveHeaderClassDesktop)" id="page-header-desktop"> 234 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null) 235 { 236 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId) 237 } 238 </header> 239 } 240 241 @if ((renderAsResponsive || renderMobile)) 242 { 243 <header class="page-header @headerCssClass top-0@(responsiveHeaderClassMobile)" id="page-header-mobile"> 244 @if (@Model.Area.Item.GetLink("HeaderMobile") != null) 245 { 246 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId) 247 } 248 </header> 249 } 250 251 <main id="content" @productDetailPageSchemaOrg> 252 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 253 @using Dynamicweb.Ecommerce.ProductCatalog 254 @using CustomUtilities 255 @using Dynamicweb.Extensibility; 256 @using Dynamicweb.Indexing.Querying; 257 258 259 260 @{ 261 string theme = ""; 262 string gridContent = ""; 263 264 if (Model.PropertyItem != null) 265 { 266 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? " theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 267 } 268 269 if (Model.Item != null) 270 { 271 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page"); 272 } 273 274 bool doNotRenderPage = false; 275 276 //Check if we are on the poduct detail page, and if there is data to render 277 ProductViewModel product = new ProductViewModel(); 278 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 279 { 280 281 282 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 283 if (string.IsNullOrEmpty(product.Id)) 284 { 285 doNotRenderPage = true; 286 } 287 288 var currentProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, null, product.LanguageId); 289 int pageLoadPeriod = Pageview.AreaSettings.GetInt32("PageLoadPeriod"); 290 291 if (pageLoadPeriod == 0 && Model.Area.Item != null) 292 { 293 var websiteSettings = Dynamicweb.Services.Items.GetItem(Model.Area.ItemType, Model.Area.ItemId); 294 websiteSettings["PageLoadPeriod"] = 30; 295 Dynamicweb.Services.Items.SaveItem(websiteSettings); 296 297 pageLoadPeriod = 30; 298 } 299 300 301 // Custom 404 logic for product catalog based pages 302 // because there is not separate product cataloges per site and all information is tagged as Danish 303 if (!currentProduct.Active && !Pageview.IsVisualEditorMode) 304 { 305 HttpContext.Current.Response.Redirect("/404/", true); 306 } 307 308 // The "All" index has information about which site each product catalog based pages belongs to in the field "WebsiteID" 309 // The query matches WebsiteID = Pageview.Context.WebsiteID and returns only records relevant for current síte 310 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 311 var query = queryService.LoadQuery("All", "QueryAll"); 312 313 if (query == null) 314 { 315 throw new MissingMethodException("Specified query not found."); 316 } 317 318 IDictionary<string, object> parameters = new Dictionary<string, object>(); 319 parameters.Add("docID", product.Id); 320 var settings = new QuerySettings 321 { 322 Skip = 0, 323 Take = 10, 324 Parameters = parameters 325 }; 326 327 var result = queryService.Query(query, settings); 328 329 var autoIds = new List<long>(); 330 foreach (Dictionary<string, object> document in result.QueryResult) 331 { 332 var productAutoId = (long)document["AutoID"]; 333 autoIds.Add(productAutoId); 334 } 335 var products = Dynamicweb.Ecommerce.Services.Products.GetByAutoIDs(autoIds); 336 337 // 404 redirect the product page if it did not belong to the current website accoring to the All index 338 if (products.Count() == 0 && !Pageview.IsVisualEditorMode) 339 { 340 HttpContext.Current.Response.Redirect("/404/", true); 341 } 342 343 344 Helpers helper = new Helpers(); 345 346 helper.CleanPageLoadsJsonData(currentProduct, pageLoadPeriod); 347 helper.UpdatePageLoadsJsonData(currentProduct); 348 } 349 350 //Render the page 351 if (!doNotRenderPage) 352 { 353 if (theme != "") 354 { 355 <div class="@theme"> 356 @gridContent 357 </div> 358 } 359 else 360 { 361 @gridContent 362 } 363 } 364 else 365 { 366 <div class="container"> 367 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div> 368 </div> 369 } 370 371 if (!Model.IsCurrentUserAllowed) 372 { 373 int signInPage = GetPageIdByNavigationTag("SignInPage"); 374 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage"); 375 376 if (!Pageview.IsVisualEditorMode) 377 { 378 if (signInPage != 0) 379 { 380 if (signInPage != Model.ID) 381 { 382 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage); 383 } 384 else 385 { 386 if (dashboardPage != 0) 387 { 388 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage); 389 } 390 else 391 { 392 Dynamicweb.Context.Current.Response.Redirect("/"); 393 } 394 } 395 } 396 else 397 { 398 <div class="alert alert-dark m-0" role="alert"> 399 <span>@Translate("You do not have access to this page")</span> 400 </div> 401 } 402 } 403 else 404 { 405 <div class="alert alert-dark m-0" role="alert"> 406 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span> 407 </div> 408 } 409 } 410 } 411 412 </main> 413 414 @if (renderAsResponsive || !renderMobile) 415 { 416 <footer class="page-footer d-none d-lg-block" id="page-footer-desktop"> 417 @if (@Model.Area.Item.GetLink("FooterDesktop") != null) 418 { 419 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId) 420 } 421 </footer> 422 } 423 424 @if (renderAsResponsive || renderMobile) 425 { 426 <footer class="page-footer d-block d-lg-none" id="page-footer-mobile"> 427 @if (@Model.Area.Item.GetLink("FooterMobile") != null) 428 { 429 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId) 430 } 431 </footer> 432 } 433 434 @* Render any offcanvas menu here *@ 435 @RenderSnippet("offcanvas") 436 437 @* Language selector modal *@ 438 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1) 439 { 440 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true"> 441 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent"> 442 @* The content here comes from an external request *@ 443 </div> 444 </div> 445 } 446 447 @* Favorite toast *@ 448 <div aria-live="polite" aria-atomic="true"> 449 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11"> 450 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true"> 451 <div class="toast-header"> 452 <strong class="me-auto">@Translate("Favorite list updated")</strong> 453 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> 454 </div> 455 <div class="toast-body d-flex gap-3"> 456 <div id="favoriteNotificationToast_Image"></div> 457 <div id="favoriteNotificationToast_Text"></div> 458 </div> 459 </div> 460 </div> 461 </div> 462 463 @* Offcanvas for dynamic content *@ 464 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem"> 465 @* The content here comes from an external request *@ 466 </div> 467 468 <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> 469 470 <script type="text/javascript"> 471 472 window.addEventListener('CookiebotOnDecline', function (e) { 473 if (Cookiebot.declined) 474 { 475 setOptInCookie(0); 476 } 477 }, false); 478 479 window.addEventListener('CookiebotOnAccept', function (e) { 480 if (Cookiebot.consented) 481 { 482 setOptInCookie(2); 483 } 484 }, false); 485 486 async function setOptInCookie(optInLevel) { 487 let response = await fetch("/admin/public/CookieOptInLevelConfig.aspx?cmd=SetCookieOptInLevel&OptInLevel=" + optInLevel); 488 } 489 490 </script> 491 492 </body> 493 </html> 494 495 @functions { 496 497 void SetMetaTags() 498 { 499 //Verification Tokens 500 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : ""; 501 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : ""; 502 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : ""; 503 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : ""; 504 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : ""; 505 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : ""; 506 507 //Generic Site Values 508 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : ""; 509 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : ""; 510 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : ""; 511 512 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : ""; 513 514 //Page specific values 515 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : ""; 516 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image"); 517 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : ""; 518 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : ""; 519 520 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : ""; 521 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : ""; 522 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : ""; 523 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image"); 524 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : ""; 525 526 if (!string.IsNullOrEmpty(siteVerificationGoogle)) 527 { 528 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle); 529 } 530 531 if (!string.IsNullOrEmpty(openGraphFacebookAppID)) 532 { 533 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID); 534 } 535 536 if (!string.IsNullOrEmpty(openGraphType)) 537 { 538 Pageview.Meta.AddTag("og:type", openGraphType); 539 } 540 541 if (!string.IsNullOrEmpty(openGraphSiteName)) 542 { 543 Pageview.Meta.AddTag("og:site_name", openGraphSiteName); 544 } 545 546 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]) && !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"])) 547 { 548 if (!string.IsNullOrEmpty(Model.Title)) 549 { 550 Pageview.Meta.AddTag("og:title", Model.Title); 551 } 552 else 553 { 554 Pageview.Meta.AddTag("og:title", openGraphSiteTitle); 555 } 556 if (!string.IsNullOrEmpty(Model.Description)) 557 { 558 Pageview.Meta.AddTag("og:description", Model.Description); 559 } 560 else 561 { 562 Pageview.Meta.AddTag("og:description", openGraphDescription); 563 } 564 } 565 566 if (openGraphImage != null) 567 { 568 Pageview.Meta.AddTag("og:image", openGraphImage.Path); 569 } 570 571 if (!string.IsNullOrEmpty(openGraphImageALT)) 572 { 573 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT); 574 } 575 576 if (!string.IsNullOrEmpty(twitterCardSite)) 577 { 578 Pageview.Meta.AddTag("twitter:site", twitterCardSite); 579 } 580 581 if (!string.IsNullOrEmpty(twitterCardURL)) 582 { 583 Pageview.Meta.AddTag("twitter:url", twitterCardURL); 584 } 585 586 if (!string.IsNullOrEmpty(twitterCardTitle)) 587 { 588 Pageview.Meta.AddTag("twitter:title", twitterCardTitle); 589 } 590 591 if (!string.IsNullOrEmpty(twitterCardDescription)) 592 { 593 Pageview.Meta.AddTag("twitter:description", twitterCardDescription); 594 } 595 596 if (twitterCardImage != null) 597 { 598 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path); 599 } 600 601 if (!string.IsNullOrEmpty(twitterCardImageALT)) 602 { 603 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT); 604 } 605 } 606 } 607