Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Dynamicweb.Data.DatabaseConnectionProvider.CreateConnection(Boolean open)
at Dynamicweb.Data.Database.CreateConnection()
at Dynamicweb.Data.Database.CreateDataReader(CommandBuilder commandBuilder, IDbConnection connection, IDbTransaction transaction, Int32 commandTimeout)
at Dynamicweb.Ecommerce.Products.ProductRepository.GetProductById(String productId, String productVariantId, String productLanguageId)
at Dynamicweb.Ecommerce.Products.ProductService.FetchMissingProductsInternal(IProductRepository repo, IEnumerable`1 keys)
at Dynamicweb.Caching.ServiceCache`2.GetCache(IEnumerable`1 keys)
at Dynamicweb.Caching.ServiceCache`2.GetCache(TKey key)
at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, User user, Boolean showUntranslated)
at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, Boolean useAssortments)
at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId)
at CompiledRazorTemplates.Dynamic.RazorEngine_d8171719112c4231b65883c711c46659.Execute() in D:\dynamicweb.net\Solutions\Degree\proff1.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\_parsed\Swift_Page.parsed.cshtml:line 369
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()
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:53,State:0,Class:20
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2 @using System
3 @using Dynamicweb
4 @using Dynamicweb.Environment
5 @using Dynamicweb.Frontend
6 @using Dynamicweb.Ecommerce.ProductCatalog
7
8 @{
9 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
10 bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
11 bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
12 string responsiveClassDesktop = string.Empty;
13 string responsiveClassMobile = string.Empty;
14 if (renderAsResponsive)
15 {
16 responsiveClassDesktop = " d-none d-xl-block";
17 responsiveClassMobile = " d-block d-xl-none";
18 }
19
20 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
21
22 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0;
23 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0;
24 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
25
26 var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
27 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
28
29 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
30 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
31
32 // Schema.org details for PDP
33 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
34 bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
35 bool isArticlePage = Model.ItemType == "Swift_Article";
36 string schemaOrgType = string.Empty;
37
38 if (isProductDetailsPage)
39 {
40 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
41 }
42
43 if (isArticlePage)
44 {
45 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
46 }
47
48 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
49 {
50 //Branding page has been saved or the file is missing. Rewrite the file to disc.
51 if (brandingPageId > 0)
52 {
53 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
54 brandingPageview.Redirect = false;
55 brandingPageview.Output();
56 }
57 }
58
59 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
60 {
61 //Branding page has been saved or the file is missing. Rewrite the file to disc.
62 if (themePageId > 0)
63 {
64 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
65 themePageview.Redirect = false;
66 themePageview.Output();
67 }
68 }
69
70 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
71 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/dist/app.bundle.js"));
72
73 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
74
75 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
76
77 string headerCssClass = "sticky-top";
78 bool movePageBehind = false;
79
80 if (Pageview.Page.PropertyItem != null)
81 {
82 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top";
83 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
84 }
85
86 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
87 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
88
89 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
90 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID");
91 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
92 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical"));
93
94 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
95 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;");
96 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
97 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/dist/app.bundle.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;");
98 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster
99
100 SetMetaTags();
101
102 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
103
104 if (Pageview.Area.IsMaster)
105 {
106 languages.Add(Pageview.Page);
107 if (Pageview.Page.Languages != null)
108 {
109 foreach (var language in Pageview.Page.Languages)
110 {
111 languages.Add(language);
112 }
113 }
114 }
115 else
116 {
117 languages.Add(Pageview.Page.MasterPage);
118 if (Pageview.Page.MasterPage != null)
119 {
120 if (Pageview.Page.MasterPage.Languages != null)
121 {
122 foreach (var language in Pageview.Page.MasterPage.Languages)
123 {
124 languages.Add(language);
125 }
126 }
127 }
128 }
129
130 string siteLanguage = Pageview.Area.CultureInfo.Name;
131 Uri url = Dynamicweb.Context.Current.Request.Url;
132 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us
133
134 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries();
135 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies();
136 }
137 <!doctype html>
138 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
139 <head>
140 <!-- @swiftVersion -->
141 @* Required meta tags *@
142 <meta charset="utf-8">
143 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
144 <!--$$Snippet(meta)-->
145
146 <link rel="shortcut icon" href="@favicon">
147 <link rel="apple-touch-icon" href="/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png">
148
149 @Model.MetaTags
150
151 @{
152 var productService = new Dynamicweb.Ecommerce.Products.ProductService();
153 //var regularProduct = productService.GetProductById(productId, "", true);
154 var productBrand = "";
155 //regularProduct?.ProductFieldValues.GetProductFieldValue("TK_Brand").Value;
156 //var productGroup = regularProduct?.GroupPaths;
157
158 var alreadyWrittenTwoletterIsos = new List<string>();
159 @* Languages meta data *@
160 foreach (var language in languages)
161 {
162 hostName = url.Host;
163 if (language?.Area != null)
164 {
165 if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
166 {
167 hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
168 }
169 if (language != null && language.Published && language.Area.Active && language.Area.Published)
170 {
171 if (!string.IsNullOrEmpty(language.Area.DomainLock))
172 {
173 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
174 }
175 string querystring = $"Default.aspx?ID={language.ID}";
176 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
177 {
178 querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
179 }
180 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
181 {
182 querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
183 }
184 if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
185 {
186 querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
187 }
188
189 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
190 if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
191 {
192 friendlyUrl = "/";
193 }
194 string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
195
196
197 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
198 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
199 {
200 <link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
201 }
202 }
203 }
204 }
205 }
206
207 @if (!isProductDetailsPage)
208 {
209 <title>@Model.Title</title>
210 }
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 @if (disableWideBreakpoints != "disableBoth")
215 {
216 <style>
217 @@media ( min-width: 1600px ) {
218 .container-xxl,
219 .container-xl,
220 .container-lg,
221 .container-md,
222 .container-sm,
223 .container {
224 max-width: 1520px;
225 }
226 }
227 </style>
228
229
230
231 if (disableWideBreakpoints != "disableUltraWideOnly")
232 {
233 <style>
234 @@media ( min-width: 1920px ) {
235 .container-xxl,
236 .container-xl,
237 .container-lg,
238 .container-md,
239 .container-sm,
240 .container {
241 max-width: 1820px;
242 }
243 }
244 </style>
245 }
246 }
247
248 @* Branding and Themes min stylesheet *@
249 <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">
250 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
251 <script src="/Files/Templates/Designs/Swift/Assets/dist/app.bundle.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
252 <script src="/Files/Templates/Designs/Swift/Assets/js/COMM_custom.js?@jsFileInfo.LastWriteTime.Ticks" defer></script>
253
254 <script type="module">
255 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
256 swift.Scroll.hideHeadersOnScroll();
257 swift.Scroll.handleAlternativeTheme();
258 </script>
259
260 @* Google tag manager *@
261 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
262 {
263 <script>
264 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
265 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
266 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
267 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
268 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
269
270 function gtag() { dataLayer.push(arguments); }
271 </script>
272 }
273
274 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
275 {
276 var GoogleAnalyticsDebugMode = "";
277 bool isLoggedInBackendUser = false;
278
279 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null)
280 {
281 isLoggedInBackendUser = true;
282 }
283
284 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && isLoggedInBackendUser)
285 {
286 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
287 }
288
289 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
290 <script>
291 window.dataLayer = window.dataLayer || [];
292 function gtag() { dataLayer.push(arguments); }
293 gtag('js', new Date());
294 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
295 </script>
296 }
297
298 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
299 {
300 @RenderPartial($"Components/Custom/{customHeaderInclude}")
301 }
302 </head>
303 <body class="brand @(masterTheme)" id="page@(Model.ID)">
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="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
317 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null)
318 {
319 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId)
320 }
321 </header>
322 }
323
324 @if ((renderAsResponsive || renderMobile))
325 {
326 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
327 @if (@Model.Area.Item.GetLink("HeaderMobile") != null)
328 {
329 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").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 (@Model.Area.Item.GetLink("FooterDesktop") != null)
477 {
478 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId)
479 }
480 </footer>
481 }
482
483 @if (renderAsResponsive || renderMobile)
484 {
485 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
486 @if (@Model.Area.Item.GetLink("FooterMobile") != null)
487 {
488 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").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 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1)
502 {
503 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
504 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
505 @* The content here comes from an external request *@
506 </div>
507 </div>
508 }
509
510 @* Favorite toast *@
511 <div aria-live="polite" aria-atomic="true">
512 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
513 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
514 <div class="toast-header">
515 <strong class="me-auto">@Translate("Favorite list updated")</strong>
516 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
517 </div>
518 <div class="toast-body d-flex gap-3">
519 <div id="favoriteNotificationToast_Image"></div>
520 <div id="favoriteNotificationToast_Text"></div>
521 </div>
522 </div>
523 </div>
524 </div>
525
526 @* Modal for dynamic content *@
527 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
528 <div class="modal-dialog modal-dialog-centered modal-md">
529 <div class="modal-content theme light" id="DynamicModalContent">
530 @* The content here comes from an external request *@
531 </div>
532 </div>
533 </div>
534
535 @* Offcanvas for dynamic content *@
536 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem">
537 @* The content here comes from an external request *@
538 </div>
539
540 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage"))
541 {
542 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
543
544 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
545 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
546 <div class="toast-header">
547 <strong class="me-auto">@Translate("Connection down")</strong>
548 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
549 </div>
550 <div class="toast-body">
551 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
552 </div>
553 </div>
554 </div>
555 }
556 </body>
557 </html>
558
559 @functions {
560 void SetMetaTags()
561 {
562 //Verification Tokens
563 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
564 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : "";
565 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : "";
566 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : "";
567 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : "";
568 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : "";
569
570 //Generic Site Values
571 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
572 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
573 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
574
575 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
576
577 //Page specific values
578 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
579 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
580 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
581 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
582
583 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
584 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
585 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
586 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
587 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
588 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
589 bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
590
591 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
592 {
593 if (!string.IsNullOrEmpty(Model.Description))
594 {
595 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\" />");
596 }
597 else
598 {
599 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\" />");
600 }
601
602 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
603 {
604 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\" />");
605 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}\" />");
606 }
607 else if (openGraphImage != null)
608 {
609 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
610 Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\" />");
611 }
612
613 if (!string.IsNullOrEmpty(openGraphImageALT))
614 {
615 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\"");
616 }
617 if (!string.IsNullOrEmpty(twitterCardDescription))
618 {
619 Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
620 }
621
622 if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
623 {
624 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
625 }
626 else if (twitterCardImage != null)
627 {
628 Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
629 }
630
631 if (!string.IsNullOrEmpty(twitterCardImageALT))
632 {
633 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
634 }
635 }
636
637
638 if (!string.IsNullOrEmpty(Model.Description))
639 {
640 if (!isProductDetailsPage)
641 {
642 Pageview.Meta.AddTag($"<meta name=\"description\" content=\"{Model.Description}\" />");
643 }
644 }
645
646 if (!string.IsNullOrEmpty(siteVerificationGoogle))
647 {
648 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
649 }
650
651 if (!string.IsNullOrEmpty(openGraphFacebookAppID))
652 {
653 Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\" />");
654 }
655
656 if (!string.IsNullOrEmpty(openGraphType))
657 {
658 Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\" />");
659 }
660
661 if (!string.IsNullOrEmpty(openGraphSiteName))
662 {
663 Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\" />");
664 }
665
666 if (!string.IsNullOrEmpty(openGraphSiteName))
667 {
668 Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\" />");
669 }
670
671
672 else
673 {
674 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\" />");
675 }
676
677 if (!string.IsNullOrEmpty(Model.Title))
678 {
679
680 if (!isProductDetailsPage)
681 {
682 Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\"");
683
684 }
685 }
686
687 if (!string.IsNullOrEmpty(twitterCardSite))
688 {
689 Pageview.Meta.AddTag("twitter:site", twitterCardSite);
690 }
691
692 if (!string.IsNullOrEmpty(twitterCardURL))
693 {
694 Pageview.Meta.AddTag("twitter:url", twitterCardURL);
695 }
696
697 if (!string.IsNullOrEmpty(twitterCardTitle))
698 {
699 Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
700 }
701 }
702 }
703