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