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_f2570271639547ffacfae93dce3c349b.SetMetaTags() in D:\dynamicweb.net\Solutions\Capo\sundqvist-new.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\_parsed\Legacy_BloggPost.parsed.cshtml:line 622
at CompiledRazorTemplates.Dynamic.RazorEngine_f2570271639547ffacfae93dce3c349b.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 <!-- Flowbox code -->
147 @{
148 var enableFlowBoxScript = Convert.ToBoolean(Pageview.Area.Item["Enable_FlowboxScript"]);
149150 if (enableFlowBoxScript)
151 {
152 <script>
153 (function(d, id) {
154 if (!window.flowbox) { var f = function () { f.q.push(arguments); }; f.q = []; window.flowbox = f; }
155 if (d.getElementById(id)) {return;}
156 var s = d.createElement('script'), fjs = d.scripts[d.scripts.length - 1]; s.id = id; s.async = true;
157 s.src = 'https://connect.getflowbox.com/flowbox.js';
158 fjs.parentNode.insertBefore(s, fjs);
159 })(document, 'flowbox-js-embed');
160 </script>
161 }
162 }
163 <!-- End Flowbox code -->
164165 @Model.MetaTags
166167 @{
168 @* Languages meta data *@
169 foreach (var language in languages)
170 {
171 if (language?.Area != null)
172 {
173 if (language != null && language.Published && language.Active && language.Area.Active && language.Area.Published && language.Area.ID != Dynamicweb.Frontend.PageView.Current().AreaID)
174 {
175 if (!string.IsNullOrEmpty(language.Area.DomainLock))
176 {
177 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
178 }
179 string querystring = $"Default.aspx?ID={language.ID}";
180 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
181 {
182 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
183 }
184 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
185 {
186 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
187 }
188 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
189 {
190 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
191 }
192193 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
194 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
195196 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
197 }
198 }
199 }
200 }
201202 <title>@Model.Title</title>
203 @* Bootstrap + Swift stylesheet *@
204 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
205206 @if (disableWideBreakpoints != "disableBoth")
207 {
208 <style>
209 @@media ( min-width: 1600px ) {
210 .container-xxl,
211 .container-xl,
212 .container-lg,
213 .container-md,
214 .container-sm,
215 .container {
216 max-width: 1520px;
217 }
218 }
219 </style>
220221222223 if (disableWideBreakpoints != "disableUltraWideOnly")
224 {
225 <style>
226 @@media ( min-width: 1920px ) {
227 .container-xxl,
228 .container-xl,
229 .container-lg,
230 .container-md,
231 .container-sm,
232 .container {
233 max-width: 1820px;
234 }
235 }
236 </style>
237 }
238 }
239240 @* Branding and Themes min stylesheet *@
241 <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">
242 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
243 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
244245 <script type="module">
246 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
247 swift.Scroll.hideHeadersOnScroll();
248 swift.Scroll.handleAlternativeTheme();
249 </script>
250251 @* Google tag manager *@
252 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
253 {
254 <script>
255 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
256 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
257 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
258 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
259 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
260261 function gtag() { dataLayer.push(arguments); }
262 </script>
263 }
264265 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
266 {
267 var GoogleAnalyticsDebugMode = "";
268 bool isLoggedInBackendUser = false;
269270 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null)
271 {
272 isLoggedInBackendUser = true;
273 }
274275 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser)
276 {
277 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
278 }
279280 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
281 <script>
282 window.dataLayer = window.dataLayer || [];
283 function gtag() { dataLayer.push(arguments); }
284 gtag('js', new Date());
285 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
286 </script>
287 }
288289 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
290 {
291 @RenderPartial($"Components/Custom/{customHeaderInclude}")
292 }
293 </head>
294 <body class="brand @(masterTheme)" id="page@(Model.ID)">
295296 @* Google tag manager *@
297 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
298 {
299 <noscript>
300 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
301 height="0" width="0" style="display:none;visibility:hidden"></iframe>
302 </noscript>
303 }
304305 @if (renderAsResponsive || !renderMobile)
306 {
307 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop" data-store-jsn-feed-page-id="@GetPageIdByNavigationTag("StoreJsonFeed")">
308 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null)
309 {
310 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId)
311 }
312 </header>
313 }
314315 @if ((renderAsResponsive || renderMobile))
316 {
317 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop" data-store-jsn-feed-page-id="@GetPageIdByNavigationTag("StoreJsonFeed")">
318 @if (@Model.Area.Item.GetLink("HeaderMobile") != null)
319 {
320 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId)
321 }
322 </header>
323 }
324325 <main id="content" @(schemaOrgType)>
326 <div data-intersect></div>
327 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
328 @using System
329 @using System.Web
330 @using Dynamicweb.Ecommerce.ProductCatalog
331332333 @{
334 var showImage = Model.Item.GetFile("ImageMain") != null && Model.Item.GetBoolean("HideMainImage") == false;
335 }
336337 <div class="container-xl">
338 <div class="blog-post-page p-md-5 p-5 @(showImage ? "image" : "noImage")">
339 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Header")))
340 {
341 <div class="content-header">
342 <h1 class="display-3 mb-2 mt-2">@Model.Item.GetRawValueString("Header")</h1>
343 </div>
344 }
345 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Author")))
346 {
347 <div class="mb-2">
348 <span class=" fs-6">@Translate("Blog-written-by", "Publicerad av"): @Model.Item.GetRawValueString("Author"), @Model.Item.GetDateTime("Date").ToShortDateString()</span>
349 </div>
350 }
351352 <div class="mb-2" style="display: flex; justify-content: space-between;">
353 <div class="d-flex gap-2">
354 <span class="fs-6">@Translate("Blog-tags", "Taggar"): </span>
355 @if (!string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Categories")))
356 {
357 var categories = Model.Item.GetRawValueString("Categories");
358 string[] categoriesList = categories.Split(',');
359 int blogListPageId = GetPageIdByNavigationTag("Bloglist");
360361 foreach (var word in categoriesList)
362 {
363 <div>
364 <a
365 class="fs-6 category-btn"
366 style="margin-right: 5px;"
367 href="Default.aspx?id=@(blogListPageId)&BlogCategory=@word"
368 >
369 @Translate(word)
370 </a>
371 </div>
372 }
373 }
374 </div>
375 </div>
376377 @* @if (!Model.Item.GetBoolean("HideMainImage") && mainImage.Length > 0) *@
378 @if (showImage)
379 {
380 <div class="blog-post-page__image">
381 <figure class="mb-0">
382 @RenderPartial("Components/Image.cshtml", Model.Item.GetFile("ImageMain"))
383 </figure>
384 </div>
385 }
386 </div>
387 </div>
388389 <section class="blog-post-tips container-xl container-xl pb-5 pb-lg-6">
390 <div class=" theme sundqvist-primary p-md-5 p-5">
391 @Model.Placeholder("dwcontent1", "blogspost", "default:true;sort:1")
392 </div>
393 </section>
394395 <section id="mentioned-products"
396 class="blog-post-mentioned-products container-xl py-5 py-lg-6">
397 @Model.Placeholder("dwcontent2", "mentioned-products", "default:true;sort:2")
398 </section>
399400 <section id="related-reads"
401 class="container-xl blog-post-related-read py-5 py-lg-6">
402 @Model.Placeholder("dwcontent3", "related-reads", "default:true;sort:3")
403 </section>
404405406 @* Find stores modal *@
407 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
408 @using Dynamicweb
409 @using Dynamicweb.Environment
410 @using System;
411412 @helper RenderFindStoresModal()
413 {
414 <div id="findStore" class="find-store-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
415 <div class="find-store-modal-dialog">
416 <div class="find-store-modal-content">
417 <div class="find-store-modal-header">
418 <h4 class="modal-title">@Translate("FindStores", "Hitta köpställe")</h4>
419 <button type="button" class="btn btn-primary close flex center" data-dismiss="modal">×</button>
420 </div>
421 <div class="text-center loading">
422 <div class="spinner-border" role="status">
423 <span class="sr-only"></span>
424 </div>
425 </div>
426 <div class="modal-body" id="modal-body">
427 @* Load jquery as required by findstores.js *@
428 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
429 </div>
430 </div>
431 </div>
432 </div>
433434 <script>
435 // Get the modal element
436 var modal = document.getElementById("findStore");
437 // Get the <span> element that closes the modal
438 var span = document.getElementsByClassName("close")[0];
439 // When the user clicks on the <span> (x), close the modal
440 span.onclick = function () {
441 modal.style.display = "none";
442 document.body.style.overflow = "auto";
443 };
444 // When the user clicks anywhere outside of the modal, close it
445 window.onclick = function (event) {
446 if (event.target == modal) {
447 modal.style.display = "none";
448 document.body.style.overflow = "auto";
449 }
450 };
451 // Get spinner
452 var spinner = document.getElementsByClassName('loading');
453 // Load the content using AJAX when the user clicks on a link
454 var links = document.querySelectorAll("#findStoresButton");
455456 for (var i = 0; i < links.length; i++) {
457 links[i].onclick = function (event) {
458 event.preventDefault();
459 modal.style.display = "flex";
460 document.body.style.overflow = "hidden";
461 var url = "/Default.aspx?ID=" + "@GetPageIdByNavigationTag("findstores")";
462 var xhr = new XMLHttpRequest();
463464 //The specific Brand is handled in the find-stores js adding [?Brands=BLALA] to the Url.
465 xhr.onreadystatechange = function () {
466 if (xhr.readyState == 4 && xhr.status == 200) {
467 document.activeElement.blur();
468 var modalBody = document.getElementById("modal-body");
469 //get just the main content from the main find store page
470 const mainContent = xhr.responseText.match(/<main[^>]*>([\s\S]*?)<\/main>/i)[0];
471 // remove the header text
472 const divWithClassName = document.createElement("div");
473 divWithClassName.innerHTML = mainContent;
474 const myDiv = divWithClassName.querySelector(".item_swift_2columns");
475 const content = myDiv.innerHTML;
476 //populate the modal
477 modalBody.innerHTML = content;
478 //Dynamically add the scripts to the modal so the elements are bound correctly
479 var script2 = document.createElement("script");
480 script2.src = "/Files/Templates/Designs/Swift_Custom/Assets/js/find-stores.min.js";
481 script2.crossOrigin = "anonymous";
482 script2.defer = true;
483 document.getElementById("modal-body").appendChild(script2);
484 var script3 = document.createElement("script");
485 script3.src = "https://unpkg.com/axios/dist/axios.min.js";
486 document.getElementById("modal-body").appendChild(script3);
487 // Hide the loading icon when content has finished loading
488 spinner[0].remove();
489 };
490 };
491 xhr.open("GET", url, true);
492 xhr.send();
493 };
494 }
495 </script>
496 }
497498 @if (Pageview.Page.NavigationTag == "Shop")
499 {
500 @RenderFindStoresModal();
501 }
502 @RenderScrollTopButton()
503 </main>
504505 @if (renderAsResponsive || !renderMobile)
506 {
507 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
508 @if (@Model.Area.Item.GetLink("FooterDesktop") != null)
509 {
510 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
511 }
512 </footer>
513 }
514515 @if (renderAsResponsive || renderMobile)
516 {
517 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
518 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
519 {
520 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId)
521 }
522 </footer>
523 }
524525 @* Render any offcanvas menu here or *@
526 @RenderSnippet("offcanvas")
527528 @{
529 //bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
530 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable();
531 }
532533 @* Language selector modal *@
534 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
535 {
536 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
537 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
538 @* The content here comes from an external request *@
539 </div>
540 </div>
541 }
542543 @* Favorite toast *@
544 <div aria-live="polite" aria-atomic="true">
545 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
546 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
547 <div class="toast-header">
548 <strong class="me-auto">@Translate("Favorite list updated")</strong>
549 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
550 </div>
551 <div class="toast-body d-flex gap-3">
552 <div id="favoriteNotificationToast_Image"></div>
553 <div id="favoriteNotificationToast_Text"></div>
554 </div>
555 </div>
556 </div>
557 </div>
558559 @* Modal for dynamic content *@
560 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
561 <div class="modal-dialog modal-dialog-centered modal-md">
562 <div class="modal-content theme light" id="DynamicModalContent">
563 @* The content here comes from an external request *@
564 </div>
565 </div>
566 </div>
567568 @* Offcanvas for dynamic content *@
569 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
570 @* The content here comes from an external request *@
571 </div>
572573 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage"))
574 {
575 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
576577 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
578 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
579 <div class="toast-header">
580 <strong class="me-auto">@Translate("Connection down")</strong>
581 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
582 </div>
583 <div class="toast-body">
584 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
585 </div>
586 </div>
587 </div>
588 }
589 <script async="" src="https://script.extellio.com/sundqvist-se.min.js"></script>
590 </body>
591 </html>
592 @functions {
593 void SetMetaTags()
594 {
595 //Verification Tokens
596 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
597 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
598 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
599 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
600 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
601 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
602603 //Generic Site Values
604 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
605 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
606 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
607608 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
609610 //Page specific values
611 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
612 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
613 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
614 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
615616 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
617 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
618 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
619 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
620 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
621622 string blogPostMainImage = Pageview.Page.Item["ImageMain"]?.ToString();
623624 if (!string.IsNullOrEmpty(siteVerificationGoogle))
625 {
626 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
627 }
628629 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
630 {
631 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID);
632 }
633634 if (!string.IsNullOrEmpty(openGraphType))
635 {
636 Pageview.Meta.AddTag("og:type", openGraphType);
637 }
638639 if (!string.IsNullOrEmpty(openGraphSiteName))
640 {
641 Pageview.Meta.AddTag("og:site_name", openGraphSiteName);
642 }
643644 if (!string.IsNullOrEmpty(Model.Title))
645 {
646 Pageview.Meta.AddTag("og:title", Model.Title);
647 }
648 else
649 {
650 Pageview.Meta.AddTag("og:title", openGraphSiteTitle);
651 }
652653 if (!string.IsNullOrEmpty(Pageview.Page.TopImage) && openGraphImage == null)
654 {
655 Pageview.Meta.AddTag("og:image", Dynamicweb.Context.Current.Request.Url.Scheme + "://" + Dynamicweb.Context.Current.Request.Url.Host + Pageview.Page.TopImage);
656 }
657658 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
659 {
660 if (!string.IsNullOrEmpty(Model.Description))
661 {
662 Pageview.Meta.AddTag("og:description", Model.Description);
663 }
664 else
665 {
666 Pageview.Meta.AddTag("og:description", openGraphDescription);
667 }
668 if (openGraphImage != null)
669 {
670 Pageview.Meta.AddTag("og:image", openGraphImage.Path);
671 }
672673 if (Pageview.Page.ItemType == "Blogpost" && !string.IsNullOrEmpty(blogPostMainImage))
674 {
675 Pageview.Meta.AddTag("og:image", Dynamicweb.Context.Current.Request.Url.Scheme + "://" + Dynamicweb.Context.Current.Request.Url.Host + blogPostMainImage);
676 }
677678 if (!string.IsNullOrEmpty(openGraphImageALT))
679 {
680 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT);
681 }
682 if (!string.IsNullOrEmpty(twitterCardDescription))
683 {
684 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
685 }
686687 if (twitterCardImage != null)
688 {
689 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path);
690 }
691692 if (!string.IsNullOrEmpty(twitterCardImageALT))
693 {
694 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
695 }
696 }
697698 if (!string.IsNullOrEmpty(twitterCardSite))
699 {
700 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
701 }
702703 if (!string.IsNullOrEmpty(twitterCardURL))
704 {
705 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
706 }
707708 if (!string.IsNullOrEmpty(twitterCardTitle))
709 {
710 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
711 }
712 }
713 }
714715716 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
717718 @helper RenderScrollTopButton()
719 {
720 var showButton = Model.Area.Item.GetBoolean("ShowScrollTopButton");
721 string theme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ThemeScrollTop")) ? " theme " + Model.Area.Item.GetRawValueString("ThemeScrollTop").Replace(" ", "").Trim().ToLower() : "";
722723 if(showButton && !Pageview.IsVisualEditorMode == true)
724 {
725 <button class="scroll-top-button@(theme)" onclick="scrollToTop()">
726 @Model.Item.GetRawValueString("ThemeScrollTop")
727 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-up" viewBox="0 0 16 16">
728 <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"/>
729 </svg>
730 </button>
731 }
732 }
733