Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.ArgumentException: Object type cannot be converted to target type.
at RazorEngine.Compilation.CrossAppDomainCleanUp.CleanupHelper.Init(AppDomain domain, IPrinter printer)
at RazorEngine.Compilation.CrossAppDomainCleanUp.InitHelper.CreateHelper()
at RazorEngine.Compilation.ExecutionContextLessThread.CallHelperSafeHelper`2.AsAction()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at RazorEngine.Compilation.ExecutionContextLessThread.DefaultCallFunc[O](Func`1 f)
at RazorEngine.Compilation.CrossAppDomainCleanUp..ctor(AppDomain toWatch, IPrinter printer)
at RazorEngine.Compilation.CrossAppDomainCleanUp.CreateInitial()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at RazorEngine.Compilation.CrossAppDomainCleanUp.RegisterCleanup(String item, Boolean throwOnDefault)
at RazorEngine.Templating.InvalidatingCachingProvider.CacheTemplate(ICompiledTemplate template, ITemplateKey templateKey)
at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
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 @functions {
8 string GetCookieOptInPermission(string category)
9 {
10 bool categoryOrAllGranted = false;
11 12 if (CookieManager.IsCookieManagementActive)
13 {
14 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
15 var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
16 categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
17 }
18 19 return categoryOrAllGranted ? "granted" : "denied";
20 }
21 22 bool AllowTracking()
23 {
24 bool allowTracking = true;
25 if (CookieManager.IsCookieManagementActive)
26 {
27 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
28 var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
29 30 bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
31 bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
32 bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
33 34 allowTracking = consentAtLeastOne;
35 }
36 return allowTracking;
37 }
38 }
39 40 @{
41 var cartSummaryPageId = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Model.Area.ID, "CartSummary")?.ID;
42 bool enableMiniCart = Model.Area.Item?.GetBoolean("EnableOffcanvasMiniCart") ?? false;
43 var offcanvasMiniCartBehaviour = Model.Area.Item?.GetRawValueString("OffcanvasMinicartBehaviour", "3") ?? "3";
44 bool miniCartEnabled = cartSummaryPageId != null && enableMiniCart;
45 var brandingPageId = Model.Area.Item?.GetInt32("BrandingPage") ?? 0;
46 var themePageId = Model.Area.Item?.GetInt32("ThemesPage") ?? 0;
47 var cssPageId = Model.Area.Item?.GetInt32("CssPage") ?? 0;
48 var brandingPage = brandingPageId != 0 ? Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null : null;
49 var themesParagraphs = themePageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(themePageId) ?? null : null;
50 var cssParagraphs = cssPageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(cssPageId) ?? null : null;
51 }
52 53 @if (themesParagraphs != null || brandingPage != null)
54 {
55 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
56 bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
57 bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
58 string responsiveClassDesktop = string.Empty;
59 string responsiveClassMobile = string.Empty;
60 if (renderAsResponsive)
61 {
62 responsiveClassDesktop = " d-none d-xl-block";
63 responsiveClassMobile = " d-block d-xl-none";
64 }
65 66 var headerDesktopLink = Model.Area.Item?.GetLink("HeaderDesktop") ?? null;
67 var headerMobileLink = Model.Area.Item?.GetLink("HeaderMobile") ?? null;
68 69 var footerDesktopLink = Model.Area.Item?.GetLink("FooterDesktop") ?? null;
70 var footerMobileLink = Model.Area.Item?.GetLink("FooterMobile") ?? null;
71 72 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
73 74 string customHeaderInclude = !string.IsNullOrEmpty(Model.Area.Item.GetRawValueString("CustomHeaderInclude")) ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
75 76 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
77 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
78 79 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
80 81 82 if (cssPageId != 0)
83 {
84 var cssFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_css_styles_{Model.Area.ID}.css"));
85 var cssParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(cssPageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
86 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < cssParagraphLastChanged.Audit.LastModifiedAt)
87 {
88 var cssPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(cssPageId);
89 cssPageview.Redirect = false;
90 cssPageview.Output();
91 }
92 }
93 94 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
95 {
96 //Branding page has been saved or the file is missing. Rewrite the file to disc.
97 if (brandingPageId > 0)
98 {
99 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
100 brandingPageview.Redirect = false;
101 brandingPageview.Output();
102 }
103 }
104105 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
106 {
107 //Branding page has been saved or the file is missing. Rewrite the file to disc.
108 if (themePageId > 0)
109 {
110 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
111 themePageview.Redirect = false;
112 themePageview.Output();
113 }
114 }
115116 // Schema.org details for PDP
117 bool isProductDetailsPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("ProductID");
118 bool isArticlePage = Model.ItemType == "Swift_Article";
119 string schemaOrgType = string.Empty;
120121 if (isProductDetailsPage)
122 {
123 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
124 }
125126 if (isArticlePage)
127 {
128 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
129 }
130131132 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
133 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
134135 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
136137 string favicon = Model.Area.Item.GetRawValueString("Favicon", "/Files/Templates/Designs/Swift/Assets/Images/favicon.png");
138 string appleTouchIcon = Model.Area.Item.GetRawValueString("AppleTouchIcon", "/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon.png");
139140 string headerCssClass = "sticky-top";
141 bool movePageBehind = false;
142143 if (Model.PropertyItem != null)
144 {
145 headerCssClass = Model.PropertyItem.GetRawValueString("MoveThisPageBehindTheHeader", "sticky-top");
146 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
147 }
148149 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
150 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
151152 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID").Trim();
153 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID").Trim();
154155 bool allowTracking = AllowTracking();
156157 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
158 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;");
159 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}>; rel=preload; as=script;");
160161162 SetMetaTags();
163164 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
165166 var masterPage = Pageview.Area.IsMaster ? Pageview.Page : Pageview.Page.MasterPage;
167 languages.Add(masterPage);
168 if (masterPage?.Languages != null)
169 {
170 foreach (var language in masterPage.Languages)
171 {
172 languages.Add(language);
173 }
174 }
175176 Uri url = Dynamicweb.Context.Current.Request.Url;
177 string hostName = url.Host;
178179 <!doctype html>
180 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
181 <head>
182 <!-- @swiftVersion -->
183 @* Required meta tags *@
184 <meta charset="utf-8">
185 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
186 <link rel="shortcut icon" href="@favicon">
187 <link rel="apple-touch-icon" href="@appleTouchIcon">
188189 @Model.MetaTags
190191 @{
192 var alreadyWrittenTwoletterIsos = new List<string>();
193 @* Languages meta data *@
194 foreach (var language in languages)
195 {
196 hostName = url.Host;
197 if (language?.Area != null)
198 {
199 if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
200 {
201 hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
202 }
203 if (language != null && language.Area != null && language.Published && language.Area.Active && language.Area.Published)
204 {
205 if (!string.IsNullOrEmpty(language.Area.DomainLock))
206 {
207 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
208 }
209 string querystring = $"Default.aspx?ID={language.ID}";
210 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
211 {
212 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
213 }
214 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
215 {
216 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
217 }
218 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
219 {
220 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
221 }
222223 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
224 if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
225 {
226 friendlyUrl = "/";
227 }
228 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
229230231 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
232 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
233 {
234 alreadyWrittenTwoletterIsos.Add(language.Area.CultureInfo.TwoLetterISOLanguageName);
235 <link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
236 }
237 }
238 }
239 }
240 }
241242 <title>@Model.Title</title>
243 @* Bootstrap + Swift stylesheet *@
244 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
245246 @if (disableWideBreakpoints != "disableBoth")
247 {
248 <style>
249 @@media ( min-width: 1600px ) {
250 .container-xxl,
251 .container-xl,
252 .container-lg,
253 .container-md,
254 .container-sm,
255 .container {
256 max-width: 1520px;
257 }
258 }
259 </style>
260261262263 if (disableWideBreakpoints != "disableUltraWideOnly")
264 {
265 <style>
266 @@media ( min-width: 1920px ) {
267 .container-xxl,
268 .container-xl,
269 .container-lg,
270 .container-md,
271 .container-sm,
272 .container {
273 max-width: 1820px;
274 }
275 }
276 </style>
277 }
278 }
279280 @* Branding and Themes min stylesheet *@
281 <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">
282 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
283 <script type="module">
284 swift.Scroll.hideHeadersOnScroll();
285 swift.Scroll.handleAlternativeTheme();
286287 //Only load if AOS
288 const aosColumns = document.querySelectorAll('[data-aos]');
289 if (aosColumns.length > 0) {
290 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
291 document.addEventListener('load.swift.assetloader', function () {
292 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
293 });
294 }
295 </script>
296297 @* Google gtag method - always include even if it is not used for anything *@
298 <script>
299 window.dataLayer = window.dataLayer || [];
300 function gtag() { dataLayer.push(arguments); }
301 </script>
302 @* Google tag manager *@
303 @if (!string.IsNullOrWhiteSpace(googleTagManagerID))
304 {
305 <script>
306 gtag('consent', 'default', {
307 'ad_storage': 'denied',
308 'ad_user_data': 'denied',
309 'ad_personalization': 'denied',
310 'analytics_storage': 'denied'
311 });
312 </script>
313 <script>
314 (function (w, d, s, l, i) {
315 w[l] = w[l] || []; w[l].push({
316 'gtm.start':
317 new Date().getTime(), event: 'gtm.js'
318 }); var f = d.getElementsByTagName(s)[0],
319 j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
320 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
321 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
322 </script>
323 if (allowTracking)
324 {
325 string adConsent = GetCookieOptInPermission("Marketing");
326 string analyticsConsent = GetCookieOptInPermission("Statistical");
327 <script>
328 gtag('consent', 'update', {
329 'ad_storage': '@adConsent',
330 'ad_user_data': '@adConsent',
331 'ad_personalization': '@adConsent',
332 'analytics_storage': '@analyticsConsent'
333 });
334 </script>
335 }
336 }
337338 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
339 {
340 var GoogleAnalyticsDebugMode = "";
341342 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
343 {
344 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
345 }
346347 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
348 <script>
349 gtag('js', new Date());
350 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
351 </script>
352 }
353354 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
355 {
356 @RenderPartial($"Components/Custom/{customHeaderInclude}")
357 }
358 </head>
359 <body class="brand @(masterTheme)" id="page@(Model.ID)">
360361 @* Google tag manager *@
362 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
363 {
364 <noscript>
365 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
366 height="0" width="0" style="display:none;visibility:hidden"></iframe>
367 </noscript>
368 }
369370 @if (renderAsResponsive || !renderMobile)
371 {
372 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
373 @if (headerDesktopLink != null)
374 {
375 @RenderGrid(headerDesktopLink.PageId)
376 }
377 </header>
378 }
379380 @if ((renderAsResponsive || renderMobile))
381 {
382 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
383 @if (headerMobileLink != null)
384 {
385 @RenderGrid(headerMobileLink.PageId)
386 }
387 </header>
388 }
389390 <div data-intersect></div>
391392 <main id="content" @(schemaOrgType)>
393 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
394 @using System
395 @using Dynamicweb.Ecommerce.ProductCatalog
396397398 @{
399 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
400 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop";
401402 bool isArticlePagePage = Model.ItemType == "Swift_Article";
403 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
404 string schemaOrgProp = string.Empty;
405 if(isArticlePagePage)
406 {
407 schemaOrgProp = "itemprop=\"articleBody\"";
408 }
409410 string theme = "";
411 string gridContent = "";
412413 if (Model.PropertyItem != null)
414 {
415 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
416 }
417418 if (Model.Item != null || Pageview.IsVisualEditorMode)
419 {
420 if (!isProductDetail)
421 {
422 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
423 }
424 else
425 {
426 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
427 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
428 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
429430 @RenderGrid(detailPageId)
431 }
432 }
433434 bool doNotRenderPage = false;
435436 //Check if we are on the poduct detail page, and if there is data to render
437 ProductViewModel product = new ProductViewModel();
438 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
439 {
440 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
441 if (string.IsNullOrEmpty(product.Id)) {
442 doNotRenderPage = true;
443 }
444 }
445446 //Render the page
447 if (!doNotRenderPage) {
448 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
449450 if (Pageview.IsVisualEditorMode) {
451 @Model.Placeholder("dwcontent", "content", "default:true;sort:1")
452 }
453454 <div class="@theme @itemIdentifier" @schemaOrgProp>
455 @if (isArticleListPage)
456 {
457 var hx = $"hx-get=\"{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Model.ID)}\" hx-select=\"#content\" hx-target=\"#content\" hx-swap=\"outerHTML\" hx-trigger=\"change\" hx-headers='{{\"feed\": \"true\"}}' hx-push-url=\"true\" hx-indicator=\"#ArticleFacetForm\"";
458459 <form @hx id="ArticleFacetForm">
460 @gridContent
461 </form>
462 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script>
463 <script type="module">
464 document.addEventListener('htmx:confirm', (event) => {
465 let filters = event.detail.elt.querySelectorAll('select');
466 for (var i = 0; i < filters.length; i++) {
467 let input = filters[i];
468 if (input.name && !input.value) {
469 input.name = '';
470 }
471 }
472 });
473474 document.addEventListener('htmx:beforeOnLoad', (event) => {
475 swift.Scroll.stopIntersectionObserver();
476 });
477478 document.addEventListener('htmx:afterOnLoad', () => {
479 swift.Scroll.hideHeadersOnScroll();
480 swift.Scroll.handleAlternativeTheme();
481 });
482 </script>
483 }
484 else
485 {
486 @gridContent
487 }
488 </div>
489490 } else {
491 <div class="container">
492 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
493 </div>
494 }
495496 if (!Model.IsCurrentUserAllowed)
497 {
498 int signInPage = GetPageIdByNavigationTag("SignInPage");
499 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
500501 if (!Pageview.IsVisualEditorMode)
502 {
503 if (signInPage != 0)
504 {
505 if (signInPage != Model.ID) {
506 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
507 } else {
508 if (dashboardPage != 0) {
509 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
510 } else {
511 Dynamicweb.Context.Current.Response.Redirect("/");
512 }
513 }
514 }
515 else
516 {
517 <div class="alert alert-dark m-0" role="alert">
518 <span>@Translate("You do not have access to this page")</span>
519 </div>
520 }
521 }
522 else
523 {
524 <div class="alert alert-dark m-0" role="alert">
525 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
526 </div>
527 }
528 }
529 }
530531 </main>
532533 @if (renderAsResponsive || !renderMobile)
534 {
535 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
536 @if (footerDesktopLink != null)
537 {
538 @RenderGrid(footerDesktopLink.PageId)
539 }
540 </footer>
541 }
542543 @if (renderAsResponsive || renderMobile)
544 {
545 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
546 @if (footerMobileLink != null)
547 {
548 @RenderGrid(footerMobileLink.PageId)
549 }
550 </footer>
551 }
552553 @* Render any offcanvas menu here *@
554 @RenderSnippet("offcanvas")
555556 @{
557 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
558 }
559560 @* Language selector modal *@
561 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
562 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
563 @* The content here comes from an external request *@
564 </div>
565 </div>
566567 @* Favorite toast *@
568 <div aria-live="polite" aria-atomic="true">
569 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
570 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
571 <div class="toast-header">
572 <strong class="me-auto">@Translate("Favorite list updated")</strong>
573 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
574 </div>
575 <div class="toast-body d-flex gap-3">
576 <div id="favoriteNotificationToast_Image"></div>
577 <div id="favoriteNotificationToast_Text"></div>
578 </div>
579 </div>
580 </div>
581 </div>
582583 @* Modal for dynamic content *@
584 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
585 <div class="modal-dialog modal-dialog-centered modal-md">
586 <div class="modal-content theme light" id="DynamicModalContent">
587 @* The content here comes from an external request *@
588 </div>
589 </div>
590 </div>
591592 @* Offcanvas for dynamic content *@
593 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas">
594 @* The content here comes from an external request *@
595 </div>
596597 @if (Model.Area.Item.GetBoolean("ShowErpDownMessage") && !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]))
598 {
599 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
600601 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
602 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
603 <div class="toast-header">
604 <strong class="me-auto">@Translate("Connection down")</strong>
605 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
606 </div>
607 <div class="toast-body">
608 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
609 </div>
610 </div>
611 </div>
612 }
613614 @if (miniCartEnabled)
615 {
616 @* Open MiniCart when the cart is updated *@
617 <script type="module">
618 document.addEventListener('updated.swift.cart', (event) => {
619 let orderContext = event?.detail?.formData?.get("OrderContext");
620 updateCartSummary(orderContext);
621622 @if (offcanvasMiniCartBehaviour == "2" || offcanvasMiniCartBehaviour == "3") {
623 <text>openMiniCartOffcanvas();</text>
624 }
625 });
626 </script>
627628 if (offcanvasMiniCartBehaviour == "1" || offcanvasMiniCartBehaviour == "3")
629 {
630 @* Open MiniCart when toggle is clicked *@
631 <script type="module">
632 let miniCartToggles = document.querySelectorAll('.mini-cart-quantity');
633 miniCartToggles?.forEach((toggle) => {
634 toggle.parentElement.addEventListener('click', (event) => {
635 event.preventDefault();
636 let orderContext = toggle.dataset?.orderContext;
637 updateCartSummary(orderContext);
638639 openMiniCartOffcanvas();
640 });
641 });
642 </script>
643 }
644645 <script>
646647 const updateCartSummary = (orderContext) => {
648 const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
649 swift.PageUpdater.UpdateFromUrlInline(event, '/Default.aspx?ID=@(cartSummaryPageId)&CartType=minicart&RequestPageID=@(Pageview.Page.ID)&OrderContext=' + orderContext +'', 'Swift_CartSummary.cshtml', dynamicOffcanvas);
650 };
651652 const openMiniCartOffcanvas = () => {
653 const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
654 const miniCartOffcanvas = bootstrap.Offcanvas.getOrCreateInstance(dynamicOffcanvas);
655 dynamicOffcanvas.classList.add('overflow-y-auto');
656657 if (!miniCartOffcanvas._isShown) {
658 miniCartOffcanvas.show();
659 hideActiveOffcanvases(miniCartOffcanvas);
660 }
661 };
662663 const hideActiveOffcanvases = (miniCartOffcanvas) => {
664 let activeOffcanvases = document.querySelectorAll('.offcanvas.show');
665 activeOffcanvases?.forEach((offCanvas) => {
666 offCanvas = bootstrap.Offcanvas.getInstance(offCanvas);
667 if (offCanvas !== miniCartOffcanvas) {
668 offCanvas.hide();
669 }
670 });
671 };
672673 </script>
674 }
675676 </body>
677678 </html>
679680 }
681 else if (Pageview.IsVisualEditorMode)
682 {
683 <head>
684 <title>@Model.Title</title>
685 @* Bootstrap + Swift stylesheet *@
686 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css" rel="stylesheet" media="all" type="text/css">
687 </head>
688 <body class="p-3">
689 <div class="alert alert-danger" role="alert">
690 @Translate("Basic Swift setup is needed!")
691 </div>
692693 @if (brandingPage == null)
694 {
695 <div class="alert alert-warning" role="alert">
696 @Translate("Please add a Branding page and reference it in website settings")
697 </div>
698 }
699700 @if (themesParagraphs == null)
701 {
702 <div class="alert alert-warning" role="alert">
703 @Translate("Please add a Themes collection page and reference it in website settings")
704 </div>
705 }
706 </body>
707 }
708709710 @functions {
711 void SetMetaTags()
712 {
713 //Verification Tokens
714 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
715716 //Generic Site Values
717 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
718 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
719 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
720721 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
722723 //Page specific values
724 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
725 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
726 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
727 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
728729 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
730 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
731 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
732 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
733 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
734735 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
736 {
737 if (!string.IsNullOrEmpty(Model.Description))
738 {
739 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\">");
740 }
741 else
742 {
743 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\">");
744 }
745746 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
747 {
748 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\">");
749 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\">");
750 }
751 else if (openGraphImage != null)
752 {
753 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
754 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
755 }
756757 if (!string.IsNullOrEmpty(openGraphImageALT))
758 {
759 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\">");
760 }
761 if (!string.IsNullOrEmpty(twitterCardDescription))
762 {
763 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
764 }
765766 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
767 {
768 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
769 }
770 else if (twitterCardImage != null)
771 {
772 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
773 }
774775 if (!string.IsNullOrEmpty(twitterCardImageALT))
776 {
777 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
778 }
779 }
780781 if (!string.IsNullOrEmpty(siteVerificationGoogle))
782 {
783 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
784 }
785786 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
787 {
788 Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\">");
789 }
790791 if (!string.IsNullOrEmpty(openGraphType))
792 {
793 Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\">");
794 }
795796 if (!string.IsNullOrEmpty(openGraphSiteName))
797 {
798 Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\">");
799 }
800801 if (!string.IsNullOrEmpty(openGraphSiteName))
802 {
803 Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\">");
804 }
805806 if (!string.IsNullOrEmpty(Model.Title))
807 {
808 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\">");
809 }
810 else
811 {
812 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\">");
813 }
814815 if (!string.IsNullOrEmpty(twitterCardSite))
816 {
817 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
818 }
819820 if (!string.IsNullOrEmpty(twitterCardURL))
821 {
822 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
823 }
824825 if (!string.IsNullOrEmpty(twitterCardTitle))
826 {
827 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
828 }
829 }
830 }
831