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