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_2a7af7d1c813435da346f40ff8caec1d.Execute() in D:\Solution\BKI LIVE\Files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 538
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
193
194 @*custom edit end*@
195
196
197
198 @*Add noindex nofollow on category pages but check first if added already*@
199
200 @if (!Model.MetaTags.Contains("<meta name=\"robots\" content=\"noindex,nofollow\">"))
201 {
202 @RenderSnippet("robotsProductList")
203 @Model.MetaTags
204
205
206 }
207 else {
208 @Model.MetaTags}
209
210
211 @{
212 var alreadyWrittenTwoletterIsos = new List<string>();
213 @* Languages meta data *@
214 foreach (var language in languages)
215 {
216 hostName = url.Host;
217 if (language?.Area != null)
218 {
219 if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
220 {
221 hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
222 }
223 if (language != null && language.Published && language.Area.Active && language.Area.Published)
224 {
225 if (!string.IsNullOrEmpty(language.Area.DomainLock))
226 {
227 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
228 }
229 string querystring = $"Default.aspx?ID={language.ID}";
230 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
231 {
232 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
233 }
234 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
235 {
236 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
237 }
238 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
239 {
240 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
241 }
242
243 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
244 if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
245 {
246 friendlyUrl = "/";
247 }
248 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
249
250
251 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
252 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
253 {
254 <link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
255 }
256 }
257 }
258 }
259 }
260
261 <title>@Model.Title</title>
262 @* Bootstrap + Swift stylesheet *@
263 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
264
265 @if (disableWideBreakpoints != "disableBoth")
266 {
267 <style>
268 @@media ( min-width: 1600px ) {
269 .container-xxl,
270 .container-xl,
271 .container-lg,
272 .container-md,
273 .container-sm,
274 .container {
275 max-width: 1520px;
276 }
277 }
278 </style>
279
280
281
282 if (disableWideBreakpoints != "disableUltraWideOnly")
283 {
284 <style>
285 @@media ( min-width: 1920px ) {
286 .container-xxl,
287 .container-xl,
288 .container-lg,
289 .container-md,
290 .container-sm,
291 .container {
292 max-width: 1820px;
293 }
294 }
295 </style>
296 }
297 }
298
299 @* Branding and Themes min stylesheet *@
300 <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">
301 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
302 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
303
304 <script type="module">
305 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
306 swift.Scroll.hideHeadersOnScroll();
307 swift.Scroll.handleAlternativeTheme();
308 </script>
309
310 @* Google tag manager *@
311 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
312 {
313 <script>
314 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
315 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
316 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
317 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
318 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
319
320 function gtag() { dataLayer.push(arguments); }
321 </script>
322 }
323
324 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
325 {
326 var GoogleAnalyticsDebugMode = "";
327 bool isLoggedInBackendUser = false;
328
329 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null)
330 {
331 isLoggedInBackendUser = true;
332 }
333
334 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser)
335 {
336 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
337 }
338
339 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
340 <script>
341 window.dataLayer = window.dataLayer || [];
342 function gtag() { dataLayer.push(arguments); }
343 gtag('js', new Date());
344 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
345 </script>
346 }
347
348 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
349 {
350 @RenderPartial($"Components/Custom/{customHeaderInclude}")
351 }
352 </head>
353 <body class="brand @(masterTheme)" id="page@(Model.ID)">
354
355 @* Google tag manager *@
356 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
357 {
358 <noscript>
359 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
360 height="0" width="0" style="display:none;visibility:hidden"></iframe>
361 </noscript>
362 }
363
364 @if (renderAsResponsive || !renderMobile)
365 {
366 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
367 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null)
368 {
369 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId)
370 }
371 </header>
372 }
373
374 @if ((renderAsResponsive || renderMobile))
375 {
376 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
377 @if (@Model.Area.Item.GetLink("HeaderMobile") != null)
378 {
379 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId)
380 }
381 </header>
382 }
383
384 <main id="content" @(schemaOrgType)>
385 <div data-intersect></div>
386 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
387 @using System
388 @using Dynamicweb.Ecommerce.ProductCatalog
389
390
391 @{
392 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
393 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && new[] { "shop", "shopanonymous" }.Contains(Pageview.Page.NavigationTag.ToLower()); // CUSTOM EDIT
394
395 bool isArticlePagePage = Model.ItemType == "Swift_Article";
396 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
397 string schemaOrgProp = string.Empty;
398 if(isArticlePagePage)
399 {
400 schemaOrgProp = "itemprop=\"articleBody\"";
401 }
402
403 string theme = "";
404 string gridContent = "";
405
406 if (Model.PropertyItem != null)
407 {
408 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
409 }
410
411 if (Model.Item != null || Pageview.IsVisualEditorMode)
412 {
413 if (!isProductDetail)
414 {
415 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
416 }
417 else
418 {
419 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
420 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
421 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
422
423 @RenderGrid(detailPageId)
424 }
425 }
426
427 bool doNotRenderPage = false;
428
429 //Check if we are on the poduct detail page, and if there is data to render
430 ProductViewModel product = new ProductViewModel();
431 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
432 {
433 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
434 if (string.IsNullOrEmpty(product.Id)) {
435 doNotRenderPage = true;
436 }
437 }
438
439 //Render the page
440 if (!doNotRenderPage) {
441 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
442
443
444 <div class="@theme @itemIdentifier" @schemaOrgProp>
445 @if (isArticleListPage)
446 {
447 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\"";
448
449 <form @hx id="ArticleFacetForm">
450 @gridContent
451 </form>
452 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script>
453 <script type="module">
454 document.addEventListener('htmx:confirm', (event) => {
455 let filters = event.detail.elt.querySelectorAll('select');
456 for (var i = 0; i < filters.length; i++) {
457 let input = filters[i];
458 if (input.name && !input.value) {
459 input.name = '';
460 }
461 }
462 });
463
464 document.addEventListener('htmx:beforeOnLoad', (event) => {
465 swift.Scroll.stopIntersectionObserver();
466 });
467
468 document.addEventListener('htmx:afterOnLoad', () => {
469 swift.Scroll.hideHeadersOnScroll();
470 swift.Scroll.handleAlternativeTheme();
471 });
472 </script>
473 }
474 else
475 {
476 @gridContent
477 }
478 </div>
479
480 } else {
481 <div class="container">
482 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
483 </div>
484 }
485
486 if (!Model.IsCurrentUserAllowed)
487 {
488 int signInPage = GetPageIdByNavigationTag("SignInPage");
489 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
490
491 if (!Pageview.IsVisualEditorMode)
492 {
493 if (signInPage != 0)
494 {
495 if (signInPage != Model.ID) {
496 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
497 } else {
498 if (dashboardPage != 0) {
499 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
500 } else {
501 Dynamicweb.Context.Current.Response.Redirect("/");
502 }
503 }
504 }
505 else
506 {
507 <div class="alert alert-dark m-0" role="alert">
508 <span>@Translate("You do not have access to this page")</span>
509 </div>
510 }
511 }
512 else
513 {
514 <div class="alert alert-dark m-0" role="alert">
515 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
516 </div>
517 }
518 }
519 }
520
521 </main>
522
523 @if (renderAsResponsive || !renderMobile)
524 {
525 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
526 @if (@Model.Area.Item.GetLink("FooterDesktop") != null)
527 {
528 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
529 }
530 </footer>
531 }
532
533 @if (renderAsResponsive || renderMobile)
534 {
535 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
536 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
537 {
538 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId)
539 }
540 </footer>
541 }
542
543 @* Render any offcanvas menu here *@
544 @RenderSnippet("offcanvas")
545
546 @{
547 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
548 }
549
550 @* Language selector modal *@
551 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
552 {
553 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
554 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
555 @* The content here comes from an external request *@
556 </div>
557 </div>
558 }
559
560 @* Favorite toast *@
561 <div aria-live="polite" aria-atomic="true">
562 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
563 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
564 <div class="toast-header">
565 <strong class="me-auto">@Translate("Favorite list updated")</strong>
566 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
567 </div>
568 <div class="toast-body d-flex gap-3">
569 <div id="favoriteNotificationToast_Image"></div>
570 <div id="favoriteNotificationToast_Text"></div>
571 </div>
572 </div>
573 </div>
574 </div>
575
576 @* Modal for dynamic content *@
577 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
578 <div class="modal-dialog modal-dialog-centered modal-md">
579 <div class="modal-content theme light" id="DynamicModalContent">
580 @* The content here comes from an external request *@
581 </div>
582 </div>
583 </div>
584
585 @* Offcanvas for dynamic content *@
586 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
587 @* The content here comes from an external request *@
588 </div>
589
590 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage"))
591 {
592 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
593
594 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
595 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
596 <div class="toast-header">
597 <strong class="me-auto">@Translate("Connection down")</strong>
598 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
599 </div>
600 <div class="toast-body">
601 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
602 </div>
603 </div>
604 </div>
605 }
606 </body>
607 </html>
608 @functions {
609 void SetMetaTags()
610 {
611 //Verification Tokens
612 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
613 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
614 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
615 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
616 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
617 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
618
619 //Generic Site Values
620 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
621 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
622 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
623
624 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
625
626 //Page specific values
627 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
628 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
629 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
630 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
631
632 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
633 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
634 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
635 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
636 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
637
638 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
639 {
640 if (!string.IsNullOrEmpty(Model.Description))
641 {
642 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\" />");
643 }
644 else
645 {
646 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\" />");
647 }
648
649 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
650 {
651 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\" />");
652 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}\" />");
653 }
654 else if (openGraphImage != null)
655 {
656 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
657 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
658 }
659
660 if (!string.IsNullOrEmpty(openGraphImageALT))
661 {
662 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\"/>");
663 }
664 if (!string.IsNullOrEmpty(twitterCardDescription))
665 {
666 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
667 }
668
669 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
670 {
671 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
672 }
673 else if (twitterCardImage != null)
674 {
675 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
676 }
677
678 if (!string.IsNullOrEmpty(twitterCardImageALT))
679 {
680 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
681 }
682 }
683
684 if (!string.IsNullOrEmpty(siteVerificationGoogle))
685 {
686 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
687 }
688
689 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
690 {
691 Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\" />");
692 }
693
694 if (!string.IsNullOrEmpty(openGraphType))
695 {
696 Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\" />");
697 }
698
699 if (!string.IsNullOrEmpty(openGraphSiteName))
700 {
701 Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\" />");
702 }
703
704 if (!string.IsNullOrEmpty(openGraphSiteName))
705 {
706 Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\" />");
707 }
708
709 if (!string.IsNullOrEmpty(Model.Title))
710 {
711 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\"/>");
712 }
713 else
714 {
715 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\" />");
716 }
717
718 if (!string.IsNullOrEmpty(twitterCardSite))
719 {
720 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
721 }
722
723 if (!string.IsNullOrEmpty(twitterCardURL))
724 {
725 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
726 }
727
728 if (!string.IsNullOrEmpty(twitterCardTitle))
729 {
730 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
731 }
732 }
733 }
734