Error executing template "Designs/Swift/_parsed/Legacy_BloggPost.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_86c72ae4708946f3aa7666cdd24e7c69.SetMetaTags() in D:\dynamicweb.net\Solutions\Capo\sundqvist-new.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\_parsed\Legacy_BloggPost.parsed.cshtml:line 631
at CompiledRazorTemplates.Dynamic.RazorEngine_86c72ae4708946f3aa7666cdd24e7c69.Execute() in D:\dynamicweb.net\Solutions\Capo\sundqvist-new.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\_parsed\Legacy_BloggPost.parsed.cshtml:line 99
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 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.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
26 var themesParagraphLastChanged = Dynamicweb.Content.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 bool isArticlePage = Model.ItemType == "Swift_Article";
35 string schemaOrgType = string.Empty;
36 37 if (isProductDetailsPage)
38 {
39 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
40 }
41 42 if (isArticlePage)
43 {
44 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
45 }
46 47 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
48 {
49 //Branding page has been saved or the file is missing. Rewrite the file to disc.
50 if (brandingPageId > 0)
51 {
52 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
53 brandingPageview.Redirect = false;
54 brandingPageview.Output();
55 }
56 }
57 58 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
59 {
60 //Branding page has been saved or the file is missing. Rewrite the file to disc.
61 if (themePageId > 0)
62 {
63 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
64 themePageview.Redirect = false;
65 themePageview.Output();
66 }
67 }
68 69 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
70 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
71 72 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
73 74 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
75 76 string headerCssClass = "sticky-top";
77 bool movePageBehind = false;
78 79 if (Pageview.Page.PropertyItem != null)
80 {
81 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top";
82 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
83 }
84 85 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
86 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
87 88 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
89 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID");
90 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
91 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical"));
92 93 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
94 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;");
95 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
96 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
97 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster
98 99 SetMetaTags();
100101 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
102103 if (Pageview.Area.IsMaster)
104 {
105 languages.Add(Pageview.Page);
106 if (Pageview.Page.Languages != null)
107 {
108 foreach (var language in Pageview.Page.Languages)
109 {
110 languages.Add(language);
111 }
112 }
113 }
114 else
115 {
116 languages.Add(Pageview.Page.MasterPage);
117 if (Pageview.Page.MasterPage != null)
118 {
119 if (Pageview.Page.MasterPage.Languages != null)
120 {
121 foreach (var language in Pageview.Page.MasterPage.Languages)
122 {
123 languages.Add(language);
124 }
125 }
126 }
127 }
128129 string siteLanguage = Pageview.Area.CultureInfo.Name;
130 Uri url = Dynamicweb.Context.Current.Request.Url;
131 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us
132133 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries();
134 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies();
135 }
136 <!doctype html>
137 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
138 <head>
139 <!-- @swiftVersion -->
140 @* Required meta tags *@
141 <meta charset="utf-8">
142 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
143 <link rel="shortcut icon" href="@favicon">
144 <link rel="apple-touch-icon" href="@favicon">
145146 @{
147 string blogPostMainImage = Pageview.Page.Item["ImageMain"]?.ToString();
148 if (Pageview.Page.ItemType == "Blogpost" && !string.IsNullOrEmpty(blogPostMainImage))
149 {
150 blogPostMainImage = System.Web.HttpUtility.UrlPathEncode(blogPostMainImage);
151 <meta property="og:image" content="@Dynamicweb.Context.Current.Request.Url.Scheme://@Dynamicweb.Context.Current.Request.Url.Host@blogPostMainImage" />
152 }
153 }
154155 <!-- Flowbox code -->
156 @{
157 var enableFlowBoxScript = Convert.ToBoolean(Pageview.Area.Item["Enable_FlowboxScript"]);
158159 if (enableFlowBoxScript)
160 {
161 <script>
162 (function(d, id) {
163 if (!window.flowbox) { var f = function () { f.q.push(arguments); }; f.q = []; window.flowbox = f; }
164 if (d.getElementById(id)) {return;}
165 var s = d.createElement('script'), fjs = d.scripts[d.scripts.length - 1]; s.id = id; s.async = true;
166 s.src = 'https://connect.getflowbox.com/flowbox.js';
167 fjs.parentNode.insertBefore(s, fjs);
168 })(document, 'flowbox-js-embed');
169 </script>
170 }
171 }
172 <!-- End Flowbox code -->
173174 @Model.MetaTags
175176 @{
177 @* Languages meta data *@
178 foreach (var language in languages)
179 {
180 if (language?.Area != null)
181 {
182 if (language != null && language.Published && language.Active && language.Area.Active && language.Area.Published && language.Area.ID != Dynamicweb.Frontend.PageView.Current().AreaID)
183 {
184 if (!string.IsNullOrEmpty(language.Area.DomainLock))
185 {
186 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
187 }
188 string querystring = $"Default.aspx?ID={language.ID}";
189 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
190 {
191 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
192 }
193 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
194 {
195 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
196 }
197 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
198 {
199 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
200 }
201202 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
203 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
204205 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
206 }
207 }
208 }
209 }
210211 <title>@Model.Title</title>
212 @* Bootstrap + Swift stylesheet *@
213 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
214215 @if (disableWideBreakpoints != "disableBoth")
216 {
217 <style>
218 @@media ( min-width: 1600px ) {
219 .container-xxl,
220 .container-xl,
221 .container-lg,
222 .container-md,
223 .container-sm,
224 .container {
225 max-width: 1520px;
226 }
227 }
228 </style>
229230231232 if (disableWideBreakpoints != "disableUltraWideOnly")
233 {
234 <style>
235 @@media ( min-width: 1920px ) {
236 .container-xxl,
237 .container-xl,
238 .container-lg,
239 .container-md,
240 .container-sm,
241 .container {
242 max-width: 1820px;
243 }
244 }
245 </style>
246 }
247 }
248249 @* Branding and Themes min stylesheet *@
250 <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">
251 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
252 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
253254 <script type="module">
255 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
256 swift.Scroll.hideHeadersOnScroll();
257 swift.Scroll.handleAlternativeTheme();
258 </script>
259260 @* Google tag manager *@
261 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
262 {
263 <script>
264 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
265 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
266 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
267 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
268 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
269270 function gtag() { dataLayer.push(arguments); }
271 </script>
272 }
273274 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
275 {
276 var GoogleAnalyticsDebugMode = "";
277 bool isLoggedInBackendUser = false;
278279 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null)
280 {
281 isLoggedInBackendUser = true;
282 }
283284 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser)
285 {
286 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
287 }
288289 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
290 <script>
291 window.dataLayer = window.dataLayer || [];
292 function gtag() { dataLayer.push(arguments); }
293 gtag('js', new Date());
294 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
295 </script>
296 }
297298 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
299 {
300 @RenderPartial($"Components/Custom/{customHeaderInclude}")
301 }
302 </head>
303 <body class="brand @(masterTheme)" id="page@(Model.ID)">
304305 @* Google tag manager *@
306 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
307 {
308 <noscript>
309 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
310 height="0" width="0" style="display:none;visibility:hidden"></iframe>
311 </noscript>
312 }
313314 @if (renderAsResponsive || !renderMobile)
315 {
316 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop" data-store-jsn-feed-page-id="@GetPageIdByNavigationTag("StoreJsonFeed")">
317 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null)
318 {
319 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId)
320 }
321 </header>
322 }
323324 @if ((renderAsResponsive || renderMobile))
325 {
326 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop" data-store-jsn-feed-page-id="@GetPageIdByNavigationTag("StoreJsonFeed")">
327 @if (@Model.Area.Item.GetLink("HeaderMobile") != null)
328 {
329 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId)
330 }
331 </header>
332 }
333334 <main id="content" @(schemaOrgType)>
335 <div data-intersect></div>
336 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
337 @using System
338 @using System.Web
339 @using Dynamicweb.Ecommerce.ProductCatalog
340341342 @{
343 var showImage = Model.Item.GetFile("ImageMain") != null && Model.Item.GetBoolean("HideMainImage") == false;
344 }
345346 <div class="container-xl">
347 <div class="blog-post-page p-md-5 p-5 @(showImage ? "image" : "noImage")">
348 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Header")))
349 {
350 <div class="content-header">
351 <h1 class="display-3 mb-2 mt-2">@Model.Item.GetRawValueString("Header")</h1>
352 </div>
353 }
354 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Author")))
355 {
356 <div class="mb-2">
357 <span class=" fs-6">@Translate("Blog-written-by", "Publicerad av"): @Model.Item.GetRawValueString("Author"), @Model.Item.GetDateTime("Date").ToShortDateString()</span>
358 </div>
359 }
360361 <div class="mb-2" style="display: flex; justify-content: space-between;">
362 <div class="d-flex gap-2">
363 <span class="fs-6">@Translate("Blog-tags", "Taggar"): </span>
364 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Categories")))
365 {
366 var categories = Model.Item.GetRawValueString("Categories");
367 string[] categoriesList = categories.Split(',');
368 int blogListPageId = GetPageIdByNavigationTag("Bloglist");
369370 foreach (var word in categoriesList)
371 {
372 <div>
373 <a
374 class="fs-6 category-btn"
375 style="margin-right: 5px;"
376 href="Default.aspx?id=@(blogListPageId)&BlogCategory=@word"
377 >
378 @Translate(word)
379 </a>
380 </div>
381 }
382 }
383 </div>
384 </div>
385386 @* @if (!Model.Item.GetBoolean("HideMainImage") && mainImage.Length > 0) *@
387 @if (showImage)
388 {
389 <div class="blog-post-page__image">
390 <figure class="mb-0">
391 @RenderPartial("Components/Image.cshtml", Model.Item.GetFile("ImageMain"))
392 </figure>
393 </div>
394 }
395 </div>
396 </div>
397398 <section class="blog-post-tips container-xl container-xl pb-5 pb-lg-6">
399 <div class=" theme sundqvist-primary p-md-5 p-5">
400 @Model.Placeholder("dwcontent1", "blogspost", "default:true;sort:1")
401 </div>
402 </section>
403404 <section id="mentioned-products"
405 class="blog-post-mentioned-products container-xl py-5 py-lg-6">
406 @Model.Placeholder("dwcontent2", "mentioned-products", "default:true;sort:2")
407 </section>
408409 <section id="related-reads"
410 class="container-xl blog-post-related-read py-5 py-lg-6">
411 @Model.Placeholder("dwcontent3", "related-reads", "default:true;sort:3")
412 </section>
413414415 @* Find stores modal *@
416 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
417 @using Dynamicweb
418 @using Dynamicweb.Environment
419 @using System;
420421 @helper RenderFindStoresModal()
422 {
423 <div id="findStore" class="find-store-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
424 <div class="find-store-modal-dialog">
425 <div class="find-store-modal-content">
426 <div class="find-store-modal-header">
427 <h4 class="modal-title">@Translate("FindStores", "Hitta köpställe")</h4>
428 <button type="button" class="btn btn-primary close flex center" data-dismiss="modal">×</button>
429 </div>
430 <div class="text-center loading">
431 <div class="spinner-border" role="status">
432 <span class="sr-only"></span>
433 </div>
434 </div>
435 <div class="modal-body" id="modal-body">
436 @* Load jquery as required by findstores.js *@
437 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
438 </div>
439 </div>
440 </div>
441 </div>
442443 <script>
444 // Get the modal element
445 var modal = document.getElementById("findStore");
446 // Get the <span> element that closes the modal
447 var span = document.getElementsByClassName("close")[0];
448 // When the user clicks on the <span> (x), close the modal
449 span.onclick = function () {
450 modal.style.display = "none";
451 document.body.style.overflow = "auto";
452 };
453 // When the user clicks anywhere outside of the modal, close it
454 window.onclick = function (event) {
455 if (event.target == modal) {
456 modal.style.display = "none";
457 document.body.style.overflow = "auto";
458 }
459 };
460 // Get spinner
461 var spinner = document.getElementsByClassName('loading');
462 // Load the content using AJAX when the user clicks on a link
463 var links = document.querySelectorAll("#findStoresButton");
464465 for (var i = 0; i < links.length; i++) {
466 links[i].onclick = function (event) {
467 event.preventDefault();
468 modal.style.display = "flex";
469 document.body.style.overflow = "hidden";
470 var url = "/Default.aspx?ID=" + "@GetPageIdByNavigationTag("findstores")";
471 var xhr = new XMLHttpRequest();
472473 //The specific Brand is handled in the find-stores js adding [?Brands=BLALA] to the Url.
474 xhr.onreadystatechange = function () {
475 if (xhr.readyState == 4 && xhr.status == 200) {
476 document.activeElement.blur();
477 var modalBody = document.getElementById("modal-body");
478 //get just the main content from the main find store page
479 const mainContent = xhr.responseText.match(/<main[^>]*>([\s\S]*?)<\/main>/i)[0];
480 // remove the header text
481 const divWithClassName = document.createElement("div");
482 divWithClassName.innerHTML = mainContent;
483 const myDiv = divWithClassName.querySelector(".item_swift_2columns");
484 const content = myDiv.innerHTML;
485 //populate the modal
486 modalBody.innerHTML = content;
487 //Dynamically add the scripts to the modal so the elements are bound correctly
488 var script2 = document.createElement("script");
489 script2.src = "/Files/Templates/Designs/Swift_Custom/Assets/js/find-stores.min.js";
490 script2.crossOrigin = "anonymous";
491 script2.defer = true;
492 document.getElementById("modal-body").appendChild(script2);
493 var script3 = document.createElement("script");
494 script3.src = "https://unpkg.com/axios/dist/axios.min.js";
495 document.getElementById("modal-body").appendChild(script3);
496 // Hide the loading icon when content has finished loading
497 spinner[0].remove();
498 };
499 };
500 xhr.open("GET", url, true);
501 xhr.send();
502 };
503 }
504 </script>
505 }
506507 @if (Pageview.Page.NavigationTag == "Shop")
508 {
509 @RenderFindStoresModal();
510 }
511 @RenderScrollTopButton()
512 </main>
513514 @if (renderAsResponsive || !renderMobile)
515 {
516 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
517 @if (@Model.Area.Item.GetLink("FooterDesktop") != null)
518 {
519 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
520 }
521 </footer>
522 }
523524 @if (renderAsResponsive || renderMobile)
525 {
526 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
527 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
528 {
529 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId)
530 }
531 </footer>
532 }
533534 @* Render any offcanvas menu here or *@
535 @RenderSnippet("offcanvas")
536537 @{
538 //bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
539 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable();
540 }
541542 @* Language selector modal *@
543 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
544 {
545 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
546 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
547 @* The content here comes from an external request *@
548 </div>
549 </div>
550 }
551552 @* Favorite toast *@
553 <div aria-live="polite" aria-atomic="true">
554 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
555 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
556 <div class="toast-header">
557 <strong class="me-auto">@Translate("Favorite list updated")</strong>
558 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
559 </div>
560 <div class="toast-body d-flex gap-3">
561 <div id="favoriteNotificationToast_Image"></div>
562 <div id="favoriteNotificationToast_Text"></div>
563 </div>
564 </div>
565 </div>
566 </div>
567568 @* Modal for dynamic content *@
569 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
570 <div class="modal-dialog modal-dialog-centered modal-md">
571 <div class="modal-content theme light" id="DynamicModalContent">
572 @* The content here comes from an external request *@
573 </div>
574 </div>
575 </div>
576577 @* Offcanvas for dynamic content *@
578 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
579 @* The content here comes from an external request *@
580 </div>
581582 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage"))
583 {
584 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
585586 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
587 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
588 <div class="toast-header">
589 <strong class="me-auto">@Translate("Connection down")</strong>
590 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
591 </div>
592 <div class="toast-body">
593 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
594 </div>
595 </div>
596 </div>
597 }
598 <script async="" src="https://script.extellio.com/sundqvist-se.min.js"></script>
599 </body>
600 </html>
601 @functions {
602 void SetMetaTags()
603 {
604 //Verification Tokens
605 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
606 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
607 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
608 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
609 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
610 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
611612 //Generic Site Values
613 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
614 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
615 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
616617 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
618619 //Page specific values
620 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
621 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
622 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
623 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
624625 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
626 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
627 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
628 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
629 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
630631 string blogPostMainImage = Pageview.Page.Item["ImageMain"]?.ToString();
632633 if (!string.IsNullOrEmpty(siteVerificationGoogle))
634 {
635 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
636 }
637638 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
639 {
640 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID);
641 }
642643 if (!string.IsNullOrEmpty(openGraphType))
644 {
645 Pageview.Meta.AddTag("og:type", openGraphType);
646 }
647648 if (!string.IsNullOrEmpty(openGraphSiteName))
649 {
650 Pageview.Meta.AddTag("og:site_name", openGraphSiteName);
651 }
652653 if (!string.IsNullOrEmpty(Model.Title))
654 {
655 Pageview.Meta.AddTag("og:title", Model.Title);
656 }
657 else
658 {
659 Pageview.Meta.AddTag("og:title", openGraphSiteTitle);
660 }
661662 if (!string.IsNullOrEmpty(Pageview.Page.TopImage) && openGraphImage == null)
663 {
664 Pageview.Meta.AddTag("og:image", Dynamicweb.Context.Current.Request.Url.Scheme + "://" + Dynamicweb.Context.Current.Request.Url.Host + Pageview.Page.TopImage);
665 }
666667 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
668 {
669 if (!string.IsNullOrEmpty(Model.Description))
670 {
671 Pageview.Meta.AddTag("og:description", Model.Description);
672 }
673 else
674 {
675 Pageview.Meta.AddTag("og:description", openGraphDescription);
676 }
677 if (openGraphImage != null)
678 {
679 Pageview.Meta.AddTag("og:image", openGraphImage.Path);
680 }
681682 if (Pageview.Page.ItemType == "Blogpost" && !string.IsNullOrEmpty(blogPostMainImage))
683 {
684 Pageview.Meta.AddTag("og:image", Dynamicweb.Context.Current.Request.Url.Scheme + "://" + Dynamicweb.Context.Current.Request.Url.Host + blogPostMainImage);
685 }
686687 if (!string.IsNullOrEmpty(openGraphImageALT))
688 {
689 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT);
690 }
691 if (!string.IsNullOrEmpty(twitterCardDescription))
692 {
693 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
694 }
695696 if (twitterCardImage != null)
697 {
698 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path);
699 }
700701 if (!string.IsNullOrEmpty(twitterCardImageALT))
702 {
703 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
704 }
705 }
706707 if (!string.IsNullOrEmpty(twitterCardSite))
708 {
709 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
710 }
711712 if (!string.IsNullOrEmpty(twitterCardURL))
713 {
714 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
715 }
716717 if (!string.IsNullOrEmpty(twitterCardTitle))
718 {
719 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
720 }
721 }
722 }
723724725 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
726727 @helper RenderScrollTopButton()
728 {
729 var showButton = Model.Area.Item.GetBoolean("ShowScrollTopButton");
730 string theme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ThemeScrollTop")) ? " theme " + Model.Area.Item.GetRawValueString("ThemeScrollTop").Replace(" ", "").Trim().ToLower() : "";
731732 if(showButton && !Pageview.IsVisualEditorMode == true)
733 {
734 <button class="scroll-top-button@(theme)" onclick="scrollToTop()">
735 @Model.Item.GetRawValueString("ThemeScrollTop")
736 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-up" viewBox="0 0 16 16">
737 <path fill-rule="evenodd" d="M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5z"/>
738 </svg>
739 </button>
740 }
741 }
742