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