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_0e2430558d674fdb8f388c4153d12c27.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 333
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 System
255 @using Dynamicweb.Extensibility;
256 @using Dynamicweb.Indexing.Querying;
257 @using CustomUtilities
258
259
260
261 @{
262 string theme = "";
263 string gridContent = "";
264
265 if (Model.PropertyItem != null)
266 {
267 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? " theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
268 }
269
270 if (Model.Item != null)
271 {
272 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
273 }
274
275 bool doNotRenderPage = false;
276
277 //Check if we are on the poduct detail page, and if there is data to render
278 ProductViewModel product = new ProductViewModel();
279 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
280 {
281
282
283 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
284 if (string.IsNullOrEmpty(product.Id))
285 {
286 doNotRenderPage = true;
287 }
288
289 var currentProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, null, product.LanguageId);
290 int pageLoadPeriod = Pageview.AreaSettings.GetInt32("PageLoadPeriod");
291
292 if (pageLoadPeriod == 0 && Model.Area.Item != null)
293 {
294 var websiteSettings = Dynamicweb.Services.Items.GetItem(Model.Area.ItemType, Model.Area.ItemId);
295 websiteSettings["PageLoadPeriod"] = 30;
296 Dynamicweb.Services.Items.SaveItem(websiteSettings);
297
298 pageLoadPeriod = 30;
299 }
300
301
302 // Custom 404 logic for product catalog based pages
303 // because there is not separate product cataloges per site and all information is tagged as Danish
304 if (!currentProduct.Active && !Pageview.IsVisualEditorMode)
305 {
306 HttpContext.Current.Response.Redirect("/404/", true);
307 }
308
309 // The "All" index has information about which site each product catalog based pages belongs to in the field "WebsiteID"
310 // The query matches WebsiteID = Pageview.Context.WebsiteID and returns only records relevant for current síte
311 var queryService = ServiceLocator.Current.GetInstance<IQueryService>();
312 var query = queryService.LoadQuery("All", "QueryAll");
313
314 if (query == null)
315 {
316 throw new MissingMethodException("Specified query not found.");
317 }
318
319 IDictionary<string, object> parameters = new Dictionary<string, object>();
320 parameters.Add("docID", product.Id);
321 var settings = new QuerySettings
322 {
323 Skip = 0,
324 Take = 10,
325 Parameters = parameters
326 };
327
328 var result = queryService.Query(query, settings);
329
330 var autoIds = new List<long>();
331 foreach (Dictionary<string, object> document in result.QueryResult)
332 {
333 var productAutoId = (long)document["AutoID"];
334 autoIds.Add(productAutoId);
335 }
336 var products = Dynamicweb.Ecommerce.Services.Products.GetByAutoIDs(autoIds);
337
338 // 404 redirect the product page if it did not belong to the current website accoring to the All index
339 if (products.Count() == 0 && !Pageview.IsVisualEditorMode)
340 {
341 HttpContext.Current.Response.Redirect("/404/", true);
342 }
343
344
345 Helpers helper = new Helpers();
346
347 helper.CleanPageLoadsJsonData(currentProduct, pageLoadPeriod);
348 helper.UpdatePageLoadsJsonData(currentProduct);
349 }
350
351 //Render the page
352 if (!doNotRenderPage)
353 {
354 if (theme != "")
355 {
356 <div class="@theme">
357 @gridContent
358 </div>
359 }
360 else
361 {
362 @gridContent
363 }
364 }
365 else
366 {
367 <div class="container">
368 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
369 </div>
370 }
371
372 if (!Model.IsCurrentUserAllowed)
373 {
374 int signInPage = GetPageIdByNavigationTag("SignInPage");
375 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
376
377 if (!Pageview.IsVisualEditorMode)
378 {
379 if (signInPage != 0)
380 {
381 if (signInPage != Model.ID)
382 {
383 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
384 }
385 else
386 {
387 if (dashboardPage != 0)
388 {
389 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
390 }
391 else
392 {
393 Dynamicweb.Context.Current.Response.Redirect("/");
394 }
395 }
396 }
397 else
398 {
399 <div class="alert alert-dark m-0" role="alert">
400 <span>@Translate("You do not have access to this page")</span>
401 </div>
402 }
403 }
404 else
405 {
406 <div class="alert alert-dark m-0" role="alert">
407 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
408 </div>
409 }
410 }
411 }
412
413 </main>
414
415 @if (renderAsResponsive || !renderMobile)
416 {
417 <footer class="page-footer d-none d-lg-block" id="page-footer-desktop">
418 @if (@Model.Area.Item.GetLink("FooterDesktop") != null)
419 {
420 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
421 }
422 </footer>
423 }
424
425 @if (renderAsResponsive || renderMobile)
426 {
427 <footer class="page-footer d-block d-lg-none" id="page-footer-mobile">
428 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
429 {
430 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId)
431 }
432 </footer>
433 }
434
435 @* Render any offcanvas menu here *@
436 @RenderSnippet("offcanvas")
437
438 @* Language selector modal *@
439 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
440 {
441 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
442 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
443 @* The content here comes from an external request *@
444 </div>
445 </div>
446 }
447
448 @* Favorite toast *@
449 <div aria-live="polite" aria-atomic="true">
450 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
451 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
452 <div class="toast-header">
453 <strong class="me-auto">@Translate("Favorite list updated")</strong>
454 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
455 </div>
456 <div class="toast-body d-flex gap-3">
457 <div id="favoriteNotificationToast_Image"></div>
458 <div id="favoriteNotificationToast_Text"></div>
459 </div>
460 </div>
461 </div>
462 </div>
463
464 @* Offcanvas for dynamic content *@
465 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
466 @* The content here comes from an external request *@
467 </div>
468
469 <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
470
471 <script type="text/javascript">
472
473 window.addEventListener('CookiebotOnDecline', function (e) {
474 if (Cookiebot.declined)
475 {
476 setOptInCookie(0);
477 }
478 }, false);
479
480 window.addEventListener('CookiebotOnAccept', function (e) {
481 if (Cookiebot.consented)
482 {
483 setOptInCookie(2);
484 }
485 }, false);
486
487 async function setOptInCookie(optInLevel) {
488 let response = await fetch("/admin/public/CookieOptInLevelConfig.aspx?cmd=SetCookieOptInLevel&OptInLevel=" + optInLevel);
489 }
490
491 </script>
492
493 </body>
494 </html>
495
496 @functions {
497
498 void SetMetaTags()
499 {
500 //Verification Tokens
501 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
502 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
503 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
504 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
505 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
506 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
507
508 //Generic Site Values
509 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
510 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
511 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
512
513 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
514
515 //Page specific values
516 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
517 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
518 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
519 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
520
521 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
522 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
523 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
524 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
525 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
526
527 if (!string.IsNullOrEmpty(siteVerificationGoogle))
528 {
529 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
530 }
531
532 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
533 {
534 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID);
535 }
536
537 if (!string.IsNullOrEmpty(openGraphType))
538 {
539 Pageview.Meta.AddTag("og:type", openGraphType);
540 }
541
542 if (!string.IsNullOrEmpty(openGraphSiteName))
543 {
544 Pageview.Meta.AddTag("og:site_name", openGraphSiteName);
545 }
546
547 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]) && !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
548 {
549 if (!string.IsNullOrEmpty(Model.Title))
550 {
551 Pageview.Meta.AddTag("og:title", Model.Title);
552 }
553 else
554 {
555 Pageview.Meta.AddTag("og:title", openGraphSiteTitle);
556 }
557 if (!string.IsNullOrEmpty(Model.Description))
558 {
559 Pageview.Meta.AddTag("og:description", Model.Description);
560 }
561 else
562 {
563 Pageview.Meta.AddTag("og:description", openGraphDescription);
564 }
565 }
566
567 if (openGraphImage != null)
568 {
569 Pageview.Meta.AddTag("og:image", openGraphImage.Path);
570 }
571
572 if (!string.IsNullOrEmpty(openGraphImageALT))
573 {
574 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT);
575 }
576
577 if (!string.IsNullOrEmpty(twitterCardSite))
578 {
579 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
580 }
581
582 if (!string.IsNullOrEmpty(twitterCardURL))
583 {
584 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
585 }
586
587 if (!string.IsNullOrEmpty(twitterCardTitle))
588 {
589 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
590 }
591
592 if (!string.IsNullOrEmpty(twitterCardDescription))
593 {
594 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
595 }
596
597 if (twitterCardImage != null)
598 {
599 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path);
600 }
601
602 if (!string.IsNullOrEmpty(twitterCardImageALT))
603 {
604 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
605 }
606 }
607 }
608