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