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