Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.Content.Layouts.LayoutTemplateLocator.FindLayoutTemplateForPage(Page page)
at Dynamicweb.Frontend.Content.GetLayoutForDevice(Page page, DeviceType device)
at Dynamicweb.Frontend.Content.CreateGridContent(Int32 contentId, Boolean ignoreVisualEdit)
at Dynamicweb.Frontend.Content.RenderExternalGrid(Int32 pageId, String container)
at CompiledRazorTemplates.Dynamic.RazorEngine_96dffb16e97841f69724f6f26d492252.Execute() in D:\Solution\BKI LIVE\Files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 592
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2 @using System
3 @using Dynamicweb
4 @using Dynamicweb.Environment
5 @using Dynamicweb.Frontend
6 @using S_DW_BKI_Swift.CustomModules.Helpers
7 @using S_DW_BKI_Swift.CustomModules.Extensions;
8
9 @{
10 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
11 bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
12 bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
13 string responsiveClassDesktop = string.Empty;
14 string responsiveClassMobile = string.Empty;
15 if (renderAsResponsive)
16 {
17 responsiveClassDesktop = " d-none d-xl-block";
18 responsiveClassMobile = " d-block d-xl-none";
19 }
20
21 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
22
23 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0;
24 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0;
25 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
26
27 var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
28 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
29
30 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
31 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
32
33
34 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
35 bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
36 bool isArticlePage = Model.ItemType == "Swift_Article";
37 Dynamicweb.Content.PageService ps = new Dynamicweb.Content.PageService();
38 var page = ps.GetFirstPageForArea(Dynamicweb.Frontend.PageView.Current().AreaID);
39
40
41 bool isFrontpage = Dynamicweb.Frontend.PageView.Current().Page.ID == page.ID ? true : false;
42 var getSchemaParagraph = SchemaMarkupHelpers.GetParagraphById(Pageview, "ActivateSchema");
43 bool activateOrgSchema = getSchemaParagraph != null ? Convert.ToBoolean(getSchemaParagraph.Item["ShowOrganizationShema"]) : false;
44
45
46 bool showOrgSchema = false;
47 var customSettings = SchemaMarkupHelpers.GetCustomSettings(Pageview);
48
49 bool useSchema = false;
50 if (customSettings != null)
51 {
52 useSchema = customSettings.Item["ShowSchema"] != null ? Convert.ToBoolean(customSettings.Item["ShowSchema"]) : false;
53 }
54
55 string schemaOrgType = string.Empty;
56
57 if (isProductDetailsPage)
58 {
59 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
60 }
61
62 if (isArticlePage)
63 {
64 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
65 }
66
67 if (isFrontpage)
68 {
69 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Organization\"";
70 }
71
72 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
73 {
74 //Branding page has been saved or the file is missing. Rewrite the file to disc.
75 if (brandingPageId > 0)
76 {
77 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
78 brandingPageview.Redirect = false;
79 brandingPageview.Output();
80 }
81 }
82
83 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
84 {
85 //Branding page has been saved or the file is missing. Rewrite the file to disc.
86 if (themePageId > 0)
87 {
88 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
89 themePageview.Redirect = false;
90 themePageview.Output();
91 }
92 }
93
94 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
95 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
96
97 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
98
99 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
100
101 string headerCssClass = "sticky-top";
102 bool movePageBehind = false;
103
104 if (Pageview.Page.PropertyItem != null)
105 {
106 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top";
107 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
108 }
109
110 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
111 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
112
113 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
114 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID");
115 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
116 bool allowTracking = true;
117
118 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
119 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;");
120 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
121 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
122 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster
123
124 SetMetaTags();
125
126 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
127
128 if (Pageview.Area.IsMaster)
129 {
130 languages.Add(Pageview.Page);
131 if (Pageview.Page.Languages != null)
132 {
133 foreach (var language in Pageview.Page.Languages)
134 {
135 languages.Add(language);
136 }
137 }
138 }
139 else
140 {
141 languages.Add(Pageview.Page.MasterPage);
142 if (Pageview.Page.MasterPage != null)
143 {
144 if (Pageview.Page.MasterPage.Languages != null)
145 {
146 foreach (var language in Pageview.Page.MasterPage.Languages)
147 {
148 languages.Add(language);
149 }
150 }
151 }
152 }
153
154 string siteLanguage = Pageview.Area.CultureInfo.Name;
155 Uri url = Dynamicweb.Context.Current.Request.Url;
156 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us
157
158 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries();
159 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies();
160
161 // CUSTOM ADD START
162 string customHeadScripts = CustomSettingsHelper.GetSetting<string>("CustomHeadScripts");
163 string customBodyScripts = CustomSettingsHelper.GetSetting<string>("CustomBodyScripts");
164 bool renderCustomHeadScripts = !string.IsNullOrEmpty(customHeadScripts);
165 bool renderCustomBodyScripts = !string.IsNullOrEmpty(customBodyScripts);
166
167 var currentPage = S_DW_BKI_Swift.CustomModules.Helpers.TemplateHelper.GetCurrentPage();
168 var isBCRpage = S_DW_BKI_Swift.CustomModules.Helpers.TemplateHelper.IsBCRPage(currentPage);
169 // CUSTOM ADD END
170 }
171 <!doctype html>
172 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
173 <head>
174 <!-- @swiftVersion -->
175 @if (renderCustomHeadScripts)
176 {
177 @customHeadScripts
178 }
179 @* Required meta tags *@
180 <meta charset="utf-8">
181 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
182 <link rel="shortcut icon" href="@favicon">
183 @*custom edit start*@
184 @if (isFrontpage && useSchema || activateOrgSchema && useSchema)
185 {
186 @SchemaMarkupHelpers.GetSchemaMarkupForOrganization(customSettings, Pageview)
187 }
188
189 @if (isArticlePage && useSchema)
190 {
191 @SchemaMarkupHelpers.GetSchemaMarkupForArticle(customSettings, Pageview)
192
193 }
194
195 @if (isProductDetailsPage && useSchema)
196 {
197 @SchemaMarkupHelpers.GetSchemaMarkupForProduct(customSettings, Pageview, productId)
198 }
199
200 @if (!string.IsNullOrEmpty(favicon))
201 {
202 <link rel="apple-touch-icon" href="@favicon">
203 }
204
205 @RenderSnippet("videoSchema")
206 @RenderSnippet("recipeSchema")
207 <link rel="canonical" href="@Pageview.GetCanonical()">
208
209 @*custom edit end*@
210
211
212
213 @*Add noindex nofollow on category pages but check first if added already*@
214
215 @if (!Model.MetaTags.Contains("<meta name=\"robots\" content=\"noindex,nofollow\">"))
216 {
217 @RenderSnippet("robotsProductList")
218 @Model.MetaTags
219
220
221 }
222 else
223 {
224 @Model.MetaTags}
225
226
227 @{
228 var alreadyWrittenTwoletterIsos = new List<string>();
229 @* Languages meta data *@
230 foreach (var language in languages)
231 {
232 hostName = url.Host;
233 if (language?.Area != null)
234 {
235 if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
236 {
237 hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
238 }
239 if (language != null && language.Published && language.Area.Active && language.Area.Published)
240 {
241 if (!string.IsNullOrEmpty(language.Area.DomainLock))
242 {
243 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
244 }
245 string querystring = $"Default.aspx?ID={language.ID}";
246 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
247 {
248 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
249 }
250 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
251 {
252 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
253 }
254 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
255 {
256 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
257 }
258
259 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
260 if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
261 {
262 friendlyUrl = "/";
263 }
264 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
265
266
267 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
268 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
269 {
270 <link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
271 }
272 }
273 }
274 }
275 }
276
277 <title>@Model.Title</title>
278 @* Bootstrap + Swift stylesheet *@
279 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
280
281 @if (disableWideBreakpoints != "disableBoth")
282 {
283 <style>
284 @@media ( min-width: 1600px ) {
285 .container-xxl,
286 .container-xl,
287 .container-lg,
288 .container-md,
289 .container-sm,
290 .container {
291 max-width: 1520px;
292 }
293 }
294 </style>
295
296
297
298 if (disableWideBreakpoints != "disableUltraWideOnly")
299 {
300 <style>
301 @@media ( min-width: 1920px ) {
302 .container-xxl,
303 .container-xl,
304 .container-lg,
305 .container-md,
306 .container-sm,
307 .container {
308 max-width: 1820px;
309 }
310 }
311 </style>
312 }
313 }
314
315 @* Branding and Themes min stylesheet *@
316 <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">
317 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
318 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
319
320 <script type="module">
321 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
322 swift.Scroll.hideHeadersOnScroll();
323 swift.Scroll.handleAlternativeTheme();
324 </script>
325
326 @* Google tag manager *@
327 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
328 {
329 <script>
330 @if (!renderCustomHeadScripts)
331 {
332 <text>
333 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
334 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
335 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
336 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
337 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
338 </text>
339 }
340
341 function gtag() {
342 if (dataLayer) {
343 dataLayer.push(arguments);
344 }
345 }
346 </script>
347 }
348
349 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
350 {
351 var GoogleAnalyticsDebugMode = "";
352 bool isLoggedInBackendUser = false;
353
354 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null)
355 {
356 isLoggedInBackendUser = true;
357 }
358
359 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser)
360 {
361 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
362 }
363
364 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
365 <script>
366 window.dataLayer = window.dataLayer || [];
367 function gtag() {
368 if (dataLayer) {
369 dataLayer.push(arguments);
370 }
371 }
372 gtag('js', new Date());
373 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
374 </script>
375 }
376
377 @if (!string.IsNullOrWhiteSpace(customHeaderInclude) && !isBCRpage)
378 {
379 @RenderPartial($"Components/Custom/{customHeaderInclude}")
380 }
381
382 @if (isBCRpage)
383 {
384 <link rel="stylesheet" href=https://use.typekit.net/jbn6ewy.css>
385 <style>
386 main {
387 font-family: "tomarik-poster", sans-serif !important;
388 }
389
390 main h1, main h2, main h3, main h4, main h5, main h6,
391 main .h1, main .h2, main .h3, main .h4, main .h5, main .h6,
392 main .display-1, main .display-2, main .display-3,
393 main .display-4, main .display-5, main .display-6 {
394 font-family: "citrus-gothic-solid", sans-serif !important;
395 }
396 </style>
397 }
398 </head>
399 <body class="brand @(masterTheme)" id="page@(Model.ID)">
400 @* CUSTOM EDIT START *@
401 @if (renderCustomBodyScripts)
402 {
403 @customBodyScripts
404 }
405 else
406 {
407 @* Google tag manager *@
408 if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
409 {
410 <noscript>
411 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
412 height="0" width="0" style="display:none;visibility:hidden"></iframe>
413 </noscript>
414 }
415 }
416 @* CUSTOM EDIT END *@
417
418 @if (renderAsResponsive || !renderMobile)
419 {
420 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
421 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null)
422 {
423 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId)
424 }
425 </header>
426 }
427
428 @if ((renderAsResponsive || renderMobile))
429 {
430 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
431 @if (@Model.Area.Item.GetLink("HeaderMobile") != null)
432 {
433 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId)
434 }
435 </header>
436 }
437
438 <main id="content" @(schemaOrgType)>
439 <div data-intersect></div>
440 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
441 @using System
442 @using Dynamicweb.Ecommerce.ProductCatalog
443
444
445 @{
446 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
447 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && new[] { "shop", "shopanonymous" }.Contains(Pageview.Page.NavigationTag.ToLower()); // CUSTOM EDIT
448
449 bool isArticlePagePage = Model.ItemType == "Swift_Article";
450 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
451 string schemaOrgProp = string.Empty;
452 if(isArticlePagePage)
453 {
454 schemaOrgProp = "itemprop=\"articleBody\"";
455 }
456
457 string theme = "";
458 string gridContent = "";
459
460 if (Model.PropertyItem != null)
461 {
462 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
463 }
464
465 if (Model.Item != null || Pageview.IsVisualEditorMode)
466 {
467 if (!isProductDetail)
468 {
469 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
470 }
471 else
472 {
473 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
474 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
475 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
476
477 @RenderGrid(detailPageId)
478 }
479 }
480
481 bool doNotRenderPage = false;
482
483 //Check if we are on the poduct detail page, and if there is data to render
484 ProductViewModel product = new ProductViewModel();
485 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
486 {
487 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
488 if (string.IsNullOrEmpty(product.Id)) {
489 doNotRenderPage = true;
490 }
491 }
492
493 //Render the page
494 if (!doNotRenderPage) {
495 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
496
497
498 <div class="@theme @itemIdentifier" @schemaOrgProp>
499 @if (isArticleListPage)
500 {
501 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\"";
502
503 <form @hx id="ArticleFacetForm">
504 @gridContent
505 </form>
506 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script>
507 <script type="module">
508 document.addEventListener('htmx:confirm', (event) => {
509 let filters = event.detail.elt.querySelectorAll('select');
510 for (var i = 0; i < filters.length; i++) {
511 let input = filters[i];
512 if (input.name && !input.value) {
513 input.name = '';
514 }
515 }
516 });
517
518 document.addEventListener('htmx:beforeOnLoad', (event) => {
519 swift.Scroll.stopIntersectionObserver();
520 });
521
522 document.addEventListener('htmx:afterOnLoad', () => {
523 swift.Scroll.hideHeadersOnScroll();
524 swift.Scroll.handleAlternativeTheme();
525 });
526 </script>
527 }
528 else
529 {
530 @gridContent
531 }
532 </div>
533
534 } else {
535 <div class="container">
536 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
537 </div>
538 }
539
540 if (!Model.IsCurrentUserAllowed)
541 {
542 int signInPage = GetPageIdByNavigationTag("SignInPage");
543 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
544
545 if (!Pageview.IsVisualEditorMode)
546 {
547 if (signInPage != 0)
548 {
549 if (signInPage != Model.ID) {
550 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
551 } else {
552 if (dashboardPage != 0) {
553 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
554 } else {
555 Dynamicweb.Context.Current.Response.Redirect("/");
556 }
557 }
558 }
559 else
560 {
561 <div class="alert alert-dark m-0" role="alert">
562 <span>@Translate("You do not have access to this page")</span>
563 </div>
564 }
565 }
566 else
567 {
568 <div class="alert alert-dark m-0" role="alert">
569 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
570 </div>
571 }
572 }
573 }
574
575 </main>
576
577 @if (renderAsResponsive || !renderMobile)
578 {
579 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
580 @if (@Model.Area.Item.GetLink("FooterDesktop") != null)
581 {
582 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
583 }
584 </footer>
585 }
586
587 @if (renderAsResponsive || renderMobile)
588 {
589 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
590 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
591 {
592 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId)
593 }
594 </footer>
595 }
596
597 @* Render any offcanvas menu here *@
598 @RenderSnippet("offcanvas")
599
600 @{
601 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
602 }
603
604 @* Language selector modal *@
605 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
606 {
607 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
608 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
609 @* The content here comes from an external request *@
610 </div>
611 </div>
612 }
613
614 @* Favorite toast *@
615 <div aria-live="polite" aria-atomic="true">
616 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
617 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
618 <div class="toast-header">
619 <strong class="me-auto">@Translate("Favorite list updated")</strong>
620 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
621 </div>
622 <div class="toast-body d-flex gap-3">
623 <div id="favoriteNotificationToast_Image"></div>
624 <div id="favoriteNotificationToast_Text"></div>
625 </div>
626 </div>
627 </div>
628 </div>
629
630 @* Modal for dynamic content *@
631 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
632 <div class="modal-dialog modal-dialog-centered modal-md">
633 <div class="modal-content theme light" id="DynamicModalContent">
634 @* The content here comes from an external request *@
635 </div>
636 </div>
637 </div>
638
639 @* Offcanvas for dynamic content *@
640 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
641 @* The content here comes from an external request *@
642 </div>
643
644 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage"))
645 {
646 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
647
648 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
649 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
650 <div class="toast-header">
651 <strong class="me-auto">@Translate("Connection down")</strong>
652 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
653 </div>
654 <div class="toast-body">
655 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
656 </div>
657 </div>
658 </div>
659 }
660 </body>
661 </html>
662 @functions {
663 void SetMetaTags()
664 {
665 //Verification Tokens
666 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
667 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
668 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
669 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
670 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
671 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
672
673 //Generic Site Values
674 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
675 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
676 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
677
678 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
679
680 //Page specific values
681 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
682 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
683 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
684 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
685
686 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
687 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
688 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
689 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
690 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
691
692 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
693 {
694 if (!string.IsNullOrEmpty(Model.Description))
695 {
696 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\" />");
697 }
698 else
699 {
700 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\" />");
701 }
702
703 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
704 {
705 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\" />");
706 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}\" />");
707 }
708 else if (openGraphImage != null)
709 {
710 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
711 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
712 }
713
714 if (!string.IsNullOrEmpty(openGraphImageALT))
715 {
716 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\"/>");
717 }
718 if (!string.IsNullOrEmpty(twitterCardDescription))
719 {
720 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
721 }
722
723 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
724 {
725 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
726 }
727 else if (twitterCardImage != null)
728 {
729 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
730 }
731
732 if (!string.IsNullOrEmpty(twitterCardImageALT))
733 {
734 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
735 }
736 }
737
738 if (!string.IsNullOrEmpty(siteVerificationGoogle))
739 {
740 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
741 }
742
743 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
744 {
745 Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\" />");
746 }
747
748 if (!string.IsNullOrEmpty(openGraphType))
749 {
750 Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\" />");
751 }
752
753 if (!string.IsNullOrEmpty(openGraphSiteName))
754 {
755 Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\" />");
756 }
757
758 if (!string.IsNullOrEmpty(openGraphSiteName))
759 {
760 Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\" />");
761 }
762
763 if (!string.IsNullOrEmpty(Model.Title))
764 {
765 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\"/>");
766 }
767 else
768 {
769 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\" />");
770 }
771
772 if (!string.IsNullOrEmpty(twitterCardSite))
773 {
774 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
775 }
776
777 if (!string.IsNullOrEmpty(twitterCardURL))
778 {
779 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
780 }
781
782 if (!string.IsNullOrEmpty(twitterCardTitle))
783 {
784 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
785 }
786 }
787 }
788