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