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