Error compiling template "Designs/Swift/CPQ_Page.cshtml"
Line 13: The using directive for 'System' appeared previously in this namespace
Line 15: The type or namespace name 'DW_CPQ_API' could not be found (are you missing a using directive or an assembly reference?)
Line 100: 'PageViewModel.ItemType' is obsolete: 'Use Item.SystemName'
Line 443: The type or namespace name 'ModelController' could not be found (are you missing a using directive or an assembly reference?)
Line 443: The type or namespace name 'ModelController' could not be found (are you missing a using directive or an assembly reference?)
Line 453: 'PageViewModel.ItemType' is obsolete: 'Use Item.SystemName'
Line 454: 'PageViewModel.ItemType' is obsolete: 'Use Item.SystemName'
Line 480: 'Product.PrimaryGroupId' is obsolete: 'Use 'GetPrimaryGroupId' instead'
Line 480: 'GroupService.GetGroup(string)' is obsolete: 'Use GetGroup(string groupId, string languageId) instead'
Line 580: 'IResponse.Redirect(string)' is obsolete: 'Do not use'
Line 586: 'IResponse.Redirect(string)' is obsolete: 'Do not use'
Line 590: 'IResponse.Redirect(string)' is obsolete: 'Do not use'
Line 836: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 840: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 845: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 846: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 850: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 851: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 856: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 885: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 890: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 895: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 900: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 905: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
Line 909: 'Meta.AddTag(string)' is obsolete: 'Use AddCustomTag(string) or AddTag(string, string) instead.'
1 // <auto-generated/>
2 #pragma warning disable 1591
3 namespace CompiledRazorTemplates.Dynamic
4 {
5 #line hidden
6 using System.Threading.Tasks;
7 using System.Collections.Generic;
8 using System.Linq;
9 using System;
10 using Dynamicweb;
11 using Dynamicweb.Environment;
12 using Dynamicweb.Frontend;
13 using System;
14 using Dynamicweb.Ecommerce.ProductCatalog;
15 using DW_CPQ_API;
16 internal class RazorEngine_1712d56e64754b37857c62e871b8a7e3 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
17 {
18 #pragma warning disable 1998
19 public async override global::System.Threading.Tasks.Task ExecuteAsync()
20 {
21 WriteLiteral("\n");
22 WriteLiteral("\n");
23
var cartSummaryPageId = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Model.Area.ID, "CartSummary")?.ID;
bool enableMiniCart = Model.Area.Item?.GetBoolean("EnableOffcanvasMiniCart") ?? false;
var offcanvasMiniCartBehaviour = Model.Area.Item?.GetRawValueString("OffcanvasMinicartBehaviour", "3") ?? "3";
bool miniCartEnabled = cartSummaryPageId != null && enableMiniCart;
var brandingPageId = Model.Area.Item?.GetInt32("BrandingPage") ?? 0;
var themePageId = Model.Area.Item?.GetInt32("ThemesPage") ?? 0;
var cssPageId = Model.Area.Item?.GetInt32("CssPage") ?? 0;
var brandingPage = brandingPageId != 0 ? Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null : null;
var themesParagraphs = themePageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(themePageId) ?? null : null;
var cssParagraphs = cssPageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(cssPageId) ?? null : null;
WriteLiteral("\n");
24 if (themesParagraphs != null || brandingPage != null)
{
string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
string responsiveClassDesktop = string.Empty;
string responsiveClassMobile = string.Empty;
if (renderAsResponsive)
{
responsiveClassDesktop = " d-none d-xl-block";
responsiveClassMobile = " d-block d-xl-none";
}
var headerDesktopLink = Model.Area.Item?.GetLink("HeaderDesktop") ?? null;
var headerMobileLink = Model.Area.Item?.GetLink("HeaderMobile") ?? null;
var footerDesktopLink = Model.Area.Item?.GetLink("FooterDesktop") ?? null;
var footerMobileLink = Model.Area.Item?.GetLink("FooterMobile") ?? null;
var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
string customHeaderInclude = !string.IsNullOrEmpty(Model.Area.Item.GetRawValueString("CustomHeaderInclude")) ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
if (cssPageId != 0)
{
var cssFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_css_styles_{Model.Area.ID}.css"));
var cssParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(cssPageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < cssParagraphLastChanged.Audit.LastModifiedAt)
{
var cssPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(cssPageId);
cssPageview.Redirect = false;
cssPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (brandingPageId > 0)
{
var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
brandingPageview.Redirect = false;
brandingPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (themePageId > 0)
{
var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
themePageview.Redirect = false;
themePageview.Output();
}
}
// Schema.org details for PDP
bool isProductDetailsPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("ProductID");
bool isArticlePage = Model.ItemType == "Swift_Article";
string schemaOrgType = string.Empty;
if (isProductDetailsPage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
}
if (isArticlePage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
}
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string favicon = Model.Area.Item.GetRawValueString("Favicon", "/Files/Templates/Designs/Swift/Assets/Images/favicon.png");
string appleTouchIcon = Model.Area.Item.GetRawValueString("AppleTouchIcon", "/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon.png");
string headerCssClass = "sticky-top";
bool movePageBehind = false;
if (Model.PropertyItem != null)
{
headerCssClass = Model.PropertyItem.GetRawValueString("MoveThisPageBehindTheHeader", "sticky-top");
movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
}
headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID").Trim();
string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID").Trim();
bool allowTracking = AllowTracking();
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
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;");
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}>; rel=preload; as=script;");
SetMetaTags();
List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
var masterPage = Pageview.Area.IsMaster ? Pageview.Page : Pageview.Page.MasterPage;
languages.Add(masterPage);
if (masterPage?.Languages != null)
{
foreach (var language in masterPage.Languages)
{
languages.Add(language);
}
}
Uri url = Dynamicweb.Context.Current.Request.Url;
string hostName = url.Host;
WriteLiteral(" <!doctype html>\n <html");
25 BeginWriteAttribute("lang", " lang=\"", 9006, "\"", 9064, 1);
26 WriteAttributeValue("", 9013, Pageview.Area.CultureInfo.TwoLetterISOLanguageName, 9013, 51, false);
27 EndWriteAttribute();
28 WriteLiteral(">\n <head>\n <!-- ");
29 Write(swiftVersion);
30 WriteLiteral(" -->\n");
31 WriteLiteral(" <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"height=device-height, width=device-width, initial-scale=1.0\">\n <link rel=\"shortcut icon\"");
32 BeginWriteAttribute("href", " href=\"", 9307, "\"", 9322, 1);
33 WriteAttributeValue("", 9314, favicon, 9314, 8, false);
34 EndWriteAttribute();
35 WriteLiteral(">\n <link rel=\"apple-touch-icon\"");
36 BeginWriteAttribute("href", " href=\"", 9361, "\"", 9383, 1);
37 WriteAttributeValue("", 9368, appleTouchIcon, 9368, 15, false);
38 EndWriteAttribute();
39 WriteLiteral(">\n\n ");
40 Write(Model.MetaTags);
41 WriteLiteral("\n\n");
42
var alreadyWrittenTwoletterIsos = new List<string>();
foreach (var language in languages)
{
hostName = url.Host;
if (language?.Area != null)
{
if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
{
hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
}
if (language != null && language.Area != null && language.Published && language.Area.Active && language.Area.Published)
{
if (!string.IsNullOrEmpty(language.Area.DomainLock))
{
hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
}
string querystring = $"Default.aspx?ID={language.ID}";
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
{
querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
{
querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
}
string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
{
friendlyUrl = "/";
}
string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
WriteLiteral(" <link rel=\"alternate\"");
43 BeginWriteAttribute("hreflang", " hreflang=\"", 11730, "\"", 11782, 1);
44 WriteAttributeValue("", 11741, language.Area.CultureInfo.Name.ToLower(), 11741, 41, false);
45 EndWriteAttribute();
46 BeginWriteAttribute("href", " href=\"", 11783, "\"", 11795, 1);
47 WriteAttributeValue("", 11790, href, 11790, 5, false);
48 EndWriteAttribute();
49 WriteLiteral(">\n");
50 if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
{
alreadyWrittenTwoletterIsos.Add(language.Area.CultureInfo.TwoLetterISOLanguageName);
WriteLiteral(" <link rel=\"alternate\"");
51 BeginWriteAttribute("hreflang", " hreflang=\"", 12105, "\"", 12177, 1);
52 WriteAttributeValue("", 12116, language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower(), 12116, 61, false);
53 EndWriteAttribute();
54 BeginWriteAttribute("href", " href=\"", 12178, "\"", 12190, 1);
55 WriteAttributeValue("", 12185, href, 12185, 5, false);
56 EndWriteAttribute();
57 WriteLiteral(">\n");
58 }
}
}
}
WriteLiteral("\n <title>");
59 Write(Model.Title);
60 WriteLiteral("</title>\n");
61 WriteLiteral(" <link");
62 BeginWriteAttribute("href", " href=\"", 12376, "\"", 12473, 2);
63 WriteAttributeValue("", 12383, "/Files/Templates/Designs/Swift/Assets/css/styles.css?", 12383, 53, true);
64 WriteAttributeValue("", 12436, cssStyleFileInfo.LastWriteTime.Ticks, 12436, 37, false);
65 EndWriteAttribute();
66 WriteLiteral(" rel=\"stylesheet\" media=\"all\" type=\"text/css\">\n\n");
67 if (disableWideBreakpoints != "disableBoth")
{
WriteLiteral(" <style>\n ");
68 WriteLiteral(@"@media ( min-width: 1600px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1520px;
}
}
</style>
");
69
if (disableWideBreakpoints != "disableUltraWideOnly")
{
WriteLiteral(" <style>\n ");
70 WriteLiteral(@"@media ( min-width: 1920px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1820px;
}
}
</style>
");
71 }
}
WriteLiteral(" <link");
72 BeginWriteAttribute("href", " href=\"", 13566, "\"", 13682, 4);
73 WriteAttributeValue("", 13573, "/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_", 13573, 62, true);
74 WriteAttributeValue("", 13635, Model.Area.ID, 13635, 16, false);
75 WriteAttributeValue("", 13651, ".min.css?", 13651, 9, true);
76 WriteAttributeValue("", 13660, cssLastModified.Ticks, 13660, 22, false);
77 EndWriteAttribute();
78 WriteLiteral(" rel=\"stylesheet\" media=\"all\" type=\"text/css\" data-last-modified-content=\"");
79 Write(cssLastModified);
80 WriteLiteral("\">\n <script");
81 BeginWriteAttribute("src", " src=\"", 13791, "\"", 13880, 2);
82 WriteAttributeValue("", 13797, "/Files/Templates/Designs/Swift/Assets/js/scripts.js?", 13797, 52, true);
83 WriteAttributeValue("", 13849, jsFileInfo.LastWriteTime.Ticks, 13849, 31, false);
84 EndWriteAttribute();
85 WriteLiteral(@"></script>
<script type=""module"">
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
//Only load if AOS
const aosColumns = document.querySelectorAll('[data-aos]');
if (aosColumns.length > 0) {
swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?");
86 Write(jsFileInfo.LastWriteTime.Ticks);
87 WriteLiteral(@"', 'js');
document.addEventListener('load.swift.assetloader', function () {
AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
});
}
</script>
");
88 WriteLiteral(" <script>\n window.dataLayer = window.dataLayer || [];\n function gtag() { dataLayer.push(arguments); }\n </script>\n");
89 if (!string.IsNullOrWhiteSpace(googleTagManagerID))
{
WriteLiteral(@" <script>
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '");
90 Write(googleTagManagerID);
91 WriteLiteral("\');\n </script>\n");
92 if (allowTracking)
{
string adConsent = GetCookieOptInPermission("Marketing");
string analyticsConsent = GetCookieOptInPermission("Statistical");
WriteLiteral(" <script>\n gtag(\'consent\', \'update\', {\n \'ad_storage\': \'");
93 Write(adConsent);
94 WriteLiteral("\',\n \'ad_user_data\': \'");
95 Write(adConsent);
96 WriteLiteral("\',\n \'ad_personalization\': \'");
97 Write(adConsent);
98 WriteLiteral("\',\n \'analytics_storage\': \'");
99 Write(analyticsConsent);
100 WriteLiteral("\'\n });\n </script>\n");
101 }
}
WriteLiteral("\n");
102 if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
WriteLiteral(" <script async");
103 BeginWriteAttribute("src", " src=\"", 16787, "\"", 16866, 2);
104 WriteAttributeValue("", 16793, "https://www.googletagmanager.com/gtag/js?id=", 16793, 44, true);
105 WriteAttributeValue("", 16837, googleAnalyticsMeasurementID, 16837, 29, false);
106 EndWriteAttribute();
107 WriteLiteral("></script>\n <script>\n gtag(\'js\', new Date());\n gtag(\'config\', \'");
108 Write(googleAnalyticsMeasurementID);
109 WriteLiteral("\'");
110 Write(GoogleAnalyticsDebugMode);
111 WriteLiteral(");\n </script>\n");
112 }
WriteLiteral("\n");
113 if (!string.IsNullOrWhiteSpace(customHeaderInclude))
{
Write(RenderPartial($"Components/Custom/{customHeaderInclude}"));
114
}
WriteLiteral(" </head>\n <body");
115 BeginWriteAttribute("class", " class=\"", 17236, "\"", 17264, 2);
116 WriteAttributeValue("", 17244, "brand", 17244, 5, true);
117 WriteAttributeValue(" ", 17249, masterTheme, 17250, 14, false);
118 EndWriteAttribute();
119 BeginWriteAttribute("id", " id=\"", 17265, "\"", 17285, 2);
120 WriteAttributeValue("", 17270, "page", 17270, 4, true);
121 WriteAttributeValue("", 17274, Model.ID, 17274, 11, false);
122 EndWriteAttribute();
123 WriteLiteral(">\n\n");
124 if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
{
WriteLiteral(" <noscript>\n <iframe");
125 BeginWriteAttribute("src", " src=\"", 17456, "\"", 17527, 2);
126 WriteAttributeValue("", 17462, "https://www.googletagmanager.com/ns.html?id=", 17462, 44, true);
127 WriteAttributeValue("", 17506, googleTagManagerID, 17506, 21, false);
128 EndWriteAttribute();
129 WriteLiteral("\n height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>\n </noscript>\n");
130 }
WriteLiteral("\n");
131 if (renderAsResponsive || !renderMobile)
{
WriteLiteral(" <header");
132 BeginWriteAttribute("class", " class=\"", 17737, "\"", 17803, 4);
133 WriteAttributeValue("", 17745, "page-header", 17745, 11, true);
134 WriteAttributeValue(" ", 17756, headerCssClass, 17757, 15, false);
135 WriteAttributeValue(" ", 17772, "top-0", 17773, 6, true);
136 WriteAttributeValue("", 17778, responsiveClassDesktop, 17778, 25, false);
137 EndWriteAttribute();
138 WriteLiteral(" id=\"page-header-desktop\">\n");
139 if (headerDesktopLink != null)
{
Write(RenderGrid(headerDesktopLink.PageId));
140
}
WriteLiteral(" </header>\n");
141 }
WriteLiteral("\n");
142 if ((renderAsResponsive || renderMobile))
{
WriteLiteral(" <header");
143 BeginWriteAttribute("class", " class=\"", 18086, "\"", 18151, 4);
144 WriteAttributeValue("", 18094, "page-header", 18094, 11, true);
145 WriteAttributeValue(" ", 18105, headerCssClass, 18106, 15, false);
146 WriteAttributeValue(" ", 18121, "top-0", 18122, 6, true);
147 WriteAttributeValue("", 18127, responsiveClassMobile, 18127, 24, false);
148 EndWriteAttribute();
149 WriteLiteral(" id=\"page-header-mobile\">\n");
150 if (headerMobileLink != null)
{
Write(RenderGrid(headerMobileLink.PageId));
151
}
WriteLiteral(" </header>\n");
152 }
WriteLiteral("\n <div data-intersect></div>\n\n <main id=\"content\" ");
153 Write(schemaOrgType);
154 WriteLiteral(">\n");
155 WriteLiteral("\r\n\r\n");
156
157 ModelController modelController = new ModelController(Pageview.Page.ID, Dynamicweb.Context.Current.Request.Params);
158 WriteLiteral("\t<input type=\"hidden\" id=\"model_version_id\"");
159 BeginWriteAttribute("value", " value=\"", 18776, "\"", 18817, 1);
160 WriteAttributeValue("", 18784, modelController.ModelVersionId, 18784, 33, false);
161 EndWriteAttribute();
162 WriteLiteral(" />\r\n");
163
164 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
165 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop";
166
167 bool isArticlePagePage = Model.ItemType == "Swift_Article";
168 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
169 string schemaOrgProp = string.Empty;
170 if (isArticlePagePage)
171 {
172 schemaOrgProp = "itemprop=\"articleBody\"";
173 }
174
175 string theme = "";
176 string gridContent = "";
177
178 if (Model.PropertyItem != null)
179 {
180 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
181 }
182
183 if (Model.Item != null || Pageview.IsVisualEditorMode)
184 {
185 if (!isProductDetail)
186 {
187 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
188 }
189 else
190 {
191 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
192 if (productObject != null)
193 {
194 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject?.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
195 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
196
197 Write(RenderGrid(detailPageId));
198
199 }
200 }
201 }
202
203 bool doNotRenderPage = false;
204
205 //Check if we are on the poduct detail page, and if there is data to render
206 ProductViewModel product = new ProductViewModel();
207 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
208 {
209 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
210 if (string.IsNullOrEmpty(product.Id))
211 {
212 doNotRenderPage = true;
213 }
214 }
215
216 //Render the page
217 if (!doNotRenderPage)
218 {
219 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
220
221 if (Pageview.IsVisualEditorMode)
222 {
223 Write(Model.Placeholder("dwcontent", "content", "default:true;sort:1"));
224
225 }
226
227 WriteLiteral("\t\t<div");
228 BeginWriteAttribute("class", " class=\"", 21092, "\"", 21122, 2);
229 WriteAttributeValue("", 21100, theme, 21100, 6, false);
230 WriteAttributeValue(" ", 21106, itemIdentifier, 21107, 15, false);
231 EndWriteAttribute();
232 WriteLiteral(" ");
233 Write(schemaOrgProp);
234 WriteLiteral(">\r\n");
235 if (isArticleListPage)
236 {
237 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\"";
238
239 WriteLiteral("\t\t\t\t<form ");
240 Write(hx);
241 WriteLiteral(" id=\"ArticleFacetForm\">\r\n\t\t\t\t\t");
242 Write(gridContent);
243 WriteLiteral(@"
244 </form>
245 <script type=""module"" src=""/Files/Templates/Designs/Swift/Assets/js/htmx.js""></script>
246 <script type=""module"">
247 document.addEventListener('htmx:confirm', (event) => {
248 let filters = event.detail.elt.querySelectorAll('select');
249 for (var i = 0; i < filters.length; i++) {
250 let input = filters[i];
251 if (input.name && !input.value) {
252 input.name = '';
253 }
254 }
255 });
256
257 document.addEventListener('htmx:beforeOnLoad', (event) => {
258 swift.Scroll.stopIntersectionObserver();
259 });
260
261 document.addEventListener('htmx:afterOnLoad', () => {
262 swift.Scroll.hideHeadersOnScroll();
263 swift.Scroll.handleAlternativeTheme();
264 });
265 </script>
266 ");
267 }
268 else
269 {
270 Write(gridContent);
271
272 }
273 WriteLiteral("\t\t</div>\r\n");
274
275 }
276 else
277 {
278 WriteLiteral("\t\t<div class=\"container\">\r\n\t\t\t<div class=\"alert alert-info\" role=\"alert\">");
279 Write(Translate("Sorry. There is nothing to view here"));
280 WriteLiteral("</div>\r\n\t\t</div>\r\n");
281 }
282
283 if (!Model.IsCurrentUserAllowed)
284 {
285 int signInPage = GetPageIdByNavigationTag("SignInPage");
286 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
287
288 if (!Pageview.IsVisualEditorMode)
289 {
290 if (signInPage != 0)
291 {
292 if (signInPage != Model.ID)
293 {
294 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
295 }
296 else
297 {
298 if (dashboardPage != 0)
299 {
300 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
301 }
302 else
303 {
304 Dynamicweb.Context.Current.Response.Redirect("/");
305 }
306 }
307 }
308 else
309 {
310 WriteLiteral("\t\t\t\t<div class=\"alert alert-dark m-0\" role=\"alert\">\r\n\t\t\t\t\t<span>");
311 Write(Translate("You do not have access to this page"));
312 WriteLiteral("</span>\r\n\t\t\t\t</div>\r\n");
313 }
314 }
315 else
316 {
317 WriteLiteral("\t\t\t<div class=\"alert alert-dark m-0\" role=\"alert\">\r\n\t\t\t\t<span>");
318 Write(Translate("To work on this page, you must be signed in, in the frontend"));
319 WriteLiteral("</span>\r\n\t\t\t</div>\r\n");
320 }
321 }
322 WriteLiteral("\n </main>\n\n");
323 if (renderAsResponsive || !renderMobile)
{
WriteLiteral(" <footer");
324 BeginWriteAttribute("class", " class=\"", 23548, "\"", 23592, 2);
325 WriteAttributeValue("", 23556, "page-footer", 23556, 11, true);
326 WriteAttributeValue("", 23567, responsiveClassDesktop, 23567, 25, false);
327 EndWriteAttribute();
328 WriteLiteral(" id=\"page-footer-desktop\">\n");
329 if (footerDesktopLink != null)
{
Write(RenderGrid(footerDesktopLink.PageId));
330
}
WriteLiteral(" </footer>\n");
331 }
WriteLiteral("\n");
332 if (renderAsResponsive || renderMobile)
{
WriteLiteral(" <footer");
333 BeginWriteAttribute("class", " class=\"", 23873, "\"", 23916, 2);
334 WriteAttributeValue("", 23881, "page-footer", 23881, 11, true);
335 WriteAttributeValue("", 23892, responsiveClassMobile, 23892, 24, false);
336 EndWriteAttribute();
337 WriteLiteral(" id=\"page-footer-mobile\">\n");
338 if (footerMobileLink != null)
{
Write(RenderGrid(footerMobileLink.PageId));
339
}
WriteLiteral(" </footer>\n");
340 }
WriteLiteral(" ");
341 Write(RenderSnippet("offcanvas"));
342 WriteLiteral("\n\n");
343
bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
WriteLiteral("\n");
344 WriteLiteral(" <div class=\"modal fade\" id=\"PreferencesModal\" tabindex=\"-1\" aria-hidden=\"true\">\n <div class=\"modal-dialog modal-dialog-centered modal-sm\" id=\"PreferencesModalContent\">\n");
345 WriteLiteral(" </div>\n </div>\n\n");
346 WriteLiteral(@" <div aria-live=""polite"" aria-atomic=""true"">
<div class=""position-fixed bottom-0 end-0 p-3"" style=""z-index: 11"">
<div id=""favoriteNotificationToast"" class=""toast"" role=""alert"" aria-live=""assertive"" aria-atomic=""true"">
<div class=""toast-header"">
<strong class=""me-auto"">");
347 Write(Translate("Favorite list updated"));
348 WriteLiteral(@"</strong>
<button type=""button"" class=""btn-close"" data-bs-dismiss=""toast"" aria-label=""Close""></button>
</div>
<div class=""toast-body d-flex gap-3"">
<div id=""favoriteNotificationToast_Image""></div>
<div id=""favoriteNotificationToast_Text""></div>
</div>
</div>
</div>
</div>
");
349 WriteLiteral(" <div class=\"modal fade js-product\" id=\"DynamicModal\" tabindex=\"-1\" aria-hidden=\"true\">\n <div class=\"modal-dialog modal-dialog-centered modal-md\">\n <div class=\"modal-content theme light\" id=\"DynamicModalContent\">\n");
350 WriteLiteral(" </div>\n </div>\n </div>\n\n");
351 WriteLiteral("\t\t<div class=\"offcanvas offcanvas-end theme light\" tabindex=\"-1\" id=\"DynamicOffcanvas\">\n");
352 WriteLiteral(" </div>\n\n");
353 if (Model.Area.Item.GetBoolean("ShowErpDownMessage") && !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]))
{
string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
WriteLiteral(" <div class=\"position-fixed bottom-0 end-0 p-3\" style=\"z-index: 1040\">\n <div");
354 BeginWriteAttribute("class", " class=\"", 26693, "\"", 26746, 5);
355 WriteAttributeValue("", 26701, "toast", 26701, 5, true);
356 WriteAttributeValue(" ", 26706, "fade", 26707, 5, true);
357 WriteAttributeValue(" ", 26711, "show", 26712, 5, true);
358 WriteAttributeValue(" ", 26716, "border-0", 26717, 9, true);
359 WriteAttributeValue(" ", 26725, erpDownMessageTheme, 26726, 20, false);
360 EndWriteAttribute();
361 WriteLiteral(" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n <div class=\"toast-header\">\n <strong class=\"me-auto\">");
362 Write(Translate("Connection down"));
363 WriteLiteral("</strong>\n <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"toast\" aria-label=\"Close\"></button>\n </div>\n <div class=\"toast-body\">\n ");
364 Write(Translate("We are experiencing some connectivity issues. Not all features may be available to you."));
365 WriteLiteral("\n </div>\n </div>\n </div>\n");
366 }
WriteLiteral("\n");
367 if (miniCartEnabled)
{
WriteLiteral("\t\t\t<script type=\"module\">\n\t\t\t\tdocument.addEventListener(\'updated.swift.cart\', (event) => {\n\t\t\t\t\tlet orderContext = event?.detail?.formData?.get(\"OrderContext\");\n\t\t\t\t\tupdateCartSummary(orderContext);\n\n");
368 if (offcanvasMiniCartBehaviour == "2" || offcanvasMiniCartBehaviour == "3") {
WriteLiteral("openMiniCartOffcanvas();");
369
}
WriteLiteral("\t\t\t\t});\n\t\t\t</script>\n");
370
if (offcanvasMiniCartBehaviour == "1" || offcanvasMiniCartBehaviour == "3")
{
WriteLiteral(@" <script type=""module"">
let miniCartToggles = document.querySelectorAll('.mini-cart-quantity');
miniCartToggles?.forEach((toggle) => {
toggle.parentElement.addEventListener('click', (event) => {
event.preventDefault();
let orderContext = toggle.dataset?.orderContext;
updateCartSummary(orderContext);
openMiniCartOffcanvas();
});
});
</script>
");
371 }
WriteLiteral("\t\t\t<script>\n\n\t\t\t\tconst updateCartSummary = (orderContext) => {\n\t\t\t\t\tconst dynamicOffcanvas = document.getElementById(\'DynamicOffcanvas\');\n\t\t\t\t\tswift.PageUpdater.UpdateFromUrlInline(event, \'/Default.aspx?ID=");
372 Write(cartSummaryPageId);
373 WriteLiteral("&CartType=minicart&RequestPageID=");
374 Write(Pageview.Page.ID);
375 WriteLiteral(@"&OrderContext=' + orderContext +'', 'Swift_CartSummary.cshtml', dynamicOffcanvas);
};
const openMiniCartOffcanvas = () => {
const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
const miniCartOffcanvas = bootstrap.Offcanvas.getOrCreateInstance(dynamicOffcanvas);
dynamicOffcanvas.classList.add('overflow-y-auto');
if (!miniCartOffcanvas._isShown) {
miniCartOffcanvas.show();
hideActiveOffcanvases(miniCartOffcanvas);
}
};
const hideActiveOffcanvases = (miniCartOffcanvas) => {
let activeOffcanvases = document.querySelectorAll('.offcanvas.show');
activeOffcanvases?.forEach((offCanvas) => {
offCanvas = bootstrap.Offcanvas.getInstance(offCanvas);
if (offCanvas !== miniCartOffcanvas) {
offCanvas.hide();
}
});
};
</script>
");
376 }
WriteLiteral("\n\t</body>\n\n</html>\n");
377
}
else if (Pageview.IsVisualEditorMode)
{
WriteLiteral(" <head>\n <title>");
378 Write(Model.Title);
379 WriteLiteral("</title>\n");
380 WriteLiteral(" <link href=\"/Files/Templates/Designs/Swift/Assets/css/styles.css\" rel=\"stylesheet\" media=\"all\" type=\"text/css\">\n </head>\n <body class=\"p-3\">\n <div class=\"alert alert-danger\" role=\"alert\">\n ");
381 Write(Translate("Basic Swift setup is needed!"));
382 WriteLiteral("\n </div>\n\n");
383 if (brandingPage == null)
{
WriteLiteral(" <div class=\"alert alert-warning\" role=\"alert\">\n ");
384 Write(Translate("Please add a Branding page and reference it in website settings"));
385 WriteLiteral("\n </div>\n");
386 }
WriteLiteral("\n");
387 if (themesParagraphs == null)
{
WriteLiteral(" <div class=\"alert alert-warning\" role=\"alert\">\n ");
388 Write(Translate("Please add a Themes collection page and reference it in website settings"));
389 WriteLiteral("\n </div>\n");
390 }
WriteLiteral(" </body>\n");
391 }
WriteLiteral("\n\n");
392 }
393 #pragma warning restore 1998
394
string GetCookieOptInPermission(string category)
{
bool categoryOrAllGranted = false;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
}
return categoryOrAllGranted ? "granted" : "denied";
}
bool AllowTracking()
{
bool allowTracking = true;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
allowTracking = consentAtLeastOne;
}
return allowTracking;
}
void SetMetaTags()
{
//Verification Tokens
string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
//Generic Site Values
string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
//Page specific values
string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
if (!string.IsNullOrEmpty(Model.Description))
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\">");
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\">");
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}\">");
}
else if (openGraphImage != null)
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
}
if (!string.IsNullOrEmpty(openGraphImageALT))
{
Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\">");
}
if (!string.IsNullOrEmpty(twitterCardDescription))
{
Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
}
else if (twitterCardImage != null)
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
}
if (!string.IsNullOrEmpty(twitterCardImageALT))
{
Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
}
}
if (!string.IsNullOrEmpty(siteVerificationGoogle))
{
Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
}
if (!string.IsNullOrEmpty(openGraphFacebookAppID))
{
Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\">");
}
if (!string.IsNullOrEmpty(openGraphType))
{
Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\">");
}
if (!string.IsNullOrEmpty(Model.Title))
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\">");
}
if (!string.IsNullOrEmpty(twitterCardSite))
{
Pageview.Meta.AddTag("twitter:site", twitterCardSite);
}
if (!string.IsNullOrEmpty(twitterCardURL))
{
Pageview.Meta.AddTag("twitter:url", twitterCardURL);
}
if (!string.IsNullOrEmpty(twitterCardTitle))
{
Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
}
}
}
395 }
396 #pragma warning restore 1591
397
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using System
@using Dynamicweb
@using Dynamicweb.Environment
@using Dynamicweb.Frontend
@functions {
string GetCookieOptInPermission(string category)
{
bool categoryOrAllGranted = false;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
}
return categoryOrAllGranted ? "granted" : "denied";
}
bool AllowTracking()
{
bool allowTracking = true;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
allowTracking = consentAtLeastOne;
}
return allowTracking;
}
}
@{
var cartSummaryPageId = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Model.Area.ID, "CartSummary")?.ID;
bool enableMiniCart = Model.Area.Item?.GetBoolean("EnableOffcanvasMiniCart") ?? false;
var offcanvasMiniCartBehaviour = Model.Area.Item?.GetRawValueString("OffcanvasMinicartBehaviour", "3") ?? "3";
bool miniCartEnabled = cartSummaryPageId != null && enableMiniCart;
var brandingPageId = Model.Area.Item?.GetInt32("BrandingPage") ?? 0;
var themePageId = Model.Area.Item?.GetInt32("ThemesPage") ?? 0;
var cssPageId = Model.Area.Item?.GetInt32("CssPage") ?? 0;
var brandingPage = brandingPageId != 0 ? Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null : null;
var themesParagraphs = themePageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(themePageId) ?? null : null;
var cssParagraphs = cssPageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(cssPageId) ?? null : null;
}
@if (themesParagraphs != null || brandingPage != null)
{
string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
string responsiveClassDesktop = string.Empty;
string responsiveClassMobile = string.Empty;
if (renderAsResponsive)
{
responsiveClassDesktop = " d-none d-xl-block";
responsiveClassMobile = " d-block d-xl-none";
}
var headerDesktopLink = Model.Area.Item?.GetLink("HeaderDesktop") ?? null;
var headerMobileLink = Model.Area.Item?.GetLink("HeaderMobile") ?? null;
var footerDesktopLink = Model.Area.Item?.GetLink("FooterDesktop") ?? null;
var footerMobileLink = Model.Area.Item?.GetLink("FooterMobile") ?? null;
var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
string customHeaderInclude = !string.IsNullOrEmpty(Model.Area.Item.GetRawValueString("CustomHeaderInclude")) ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
if (cssPageId != 0)
{
var cssFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_css_styles_{Model.Area.ID}.css"));
var cssParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(cssPageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < cssParagraphLastChanged.Audit.LastModifiedAt)
{
var cssPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(cssPageId);
cssPageview.Redirect = false;
cssPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (brandingPageId > 0)
{
var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
brandingPageview.Redirect = false;
brandingPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (themePageId > 0)
{
var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
themePageview.Redirect = false;
themePageview.Output();
}
}
// Schema.org details for PDP
bool isProductDetailsPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("ProductID");
bool isArticlePage = Model.ItemType == "Swift_Article";
string schemaOrgType = string.Empty;
if (isProductDetailsPage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
}
if (isArticlePage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
}
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string favicon = Model.Area.Item.GetRawValueString("Favicon", "/Files/Templates/Designs/Swift/Assets/Images/favicon.png");
string appleTouchIcon = Model.Area.Item.GetRawValueString("AppleTouchIcon", "/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon.png");
string headerCssClass = "sticky-top";
bool movePageBehind = false;
if (Model.PropertyItem != null)
{
headerCssClass = Model.PropertyItem.GetRawValueString("MoveThisPageBehindTheHeader", "sticky-top");
movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
}
headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID").Trim();
string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID").Trim();
bool allowTracking = AllowTracking();
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
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;");
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}>; rel=preload; as=script;");
SetMetaTags();
List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
var masterPage = Pageview.Area.IsMaster ? Pageview.Page : Pageview.Page.MasterPage;
languages.Add(masterPage);
if (masterPage?.Languages != null)
{
foreach (var language in masterPage.Languages)
{
languages.Add(language);
}
}
Uri url = Dynamicweb.Context.Current.Request.Url;
string hostName = url.Host;
<!doctype html>
<html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
<head>
<!-- @swiftVersion -->
@* Required meta tags *@
<meta charset="utf-8">
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="@favicon">
<link rel="apple-touch-icon" href="@appleTouchIcon">
@Model.MetaTags
@{
var alreadyWrittenTwoletterIsos = new List<string>();
@* Languages meta data *@
foreach (var language in languages)
{
hostName = url.Host;
if (language?.Area != null)
{
if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
{
hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
}
if (language != null && language.Area != null && language.Published && language.Area.Active && language.Area.Published)
{
if (!string.IsNullOrEmpty(language.Area.DomainLock))
{
hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
}
string querystring = $"Default.aspx?ID={language.ID}";
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
{
querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
{
querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
}
string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
{
friendlyUrl = "/";
}
string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
<link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
{
alreadyWrittenTwoletterIsos.Add(language.Area.CultureInfo.TwoLetterISOLanguageName);
<link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
}
}
}
}
}
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
@if (disableWideBreakpoints != "disableBoth")
{
<style>
@@media ( min-width: 1600px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1520px;
}
}
</style>
if (disableWideBreakpoints != "disableUltraWideOnly")
{
<style>
@@media ( min-width: 1920px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1820px;
}
}
</style>
}
}
@* Branding and Themes min stylesheet *@
<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">
<script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
<script type="module">
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
//Only load if AOS
const aosColumns = document.querySelectorAll('[data-aos]');
if (aosColumns.length > 0) {
swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
document.addEventListener('load.swift.assetloader', function () {
AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
});
}
</script>
@* Google gtag method - always include even if it is not used for anything *@
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
</script>
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID))
{
<script>
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
</script>
if (allowTracking)
{
string adConsent = GetCookieOptInPermission("Marketing");
string analyticsConsent = GetCookieOptInPermission("Statistical");
<script>
gtag('consent', 'update', {
'ad_storage': '@adConsent',
'ad_user_data': '@adConsent',
'ad_personalization': '@adConsent',
'analytics_storage': '@analyticsConsent'
});
</script>
}
}
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
<script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
<script>
gtag('js', new Date());
gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
</script>
}
@if (!string.IsNullOrWhiteSpace(customHeaderInclude))
{
@RenderPartial($"Components/Custom/{customHeaderInclude}")
}
</head>
<body class="brand @(masterTheme)" id="page@(Model.ID)">
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
{
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
}
@if (renderAsResponsive || !renderMobile)
{
<header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
@if (headerDesktopLink != null)
{
@RenderGrid(headerDesktopLink.PageId)
}
</header>
}
@if ((renderAsResponsive || renderMobile))
{
<header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
@if (headerMobileLink != null)
{
@RenderGrid(headerMobileLink.PageId)
}
</header>
}
<div data-intersect></div>
<main id="content" @(schemaOrgType)>
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2 @using System
3 @using Dynamicweb.Ecommerce.ProductCatalog
4 @using DW_CPQ_API
5
6
7 @{
8 ModelController modelController = new ModelController(Pageview.Page.ID, Dynamicweb.Context.Current.Request.Params);
9 <input type="hidden" id="model_version_id" value="@(modelController.ModelVersionId)" />
10
11 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
12 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop";
13
14 bool isArticlePagePage = Model.ItemType == "Swift_Article";
15 bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
16 string schemaOrgProp = string.Empty;
17 if (isArticlePagePage)
18 {
19 schemaOrgProp = "itemprop=\"articleBody\"";
20 }
21
22 string theme = "";
23 string gridContent = "";
24
25 if (Model.PropertyItem != null)
26 {
27 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
28 }
29
30 if (Model.Item != null || Pageview.IsVisualEditorMode)
31 {
32 if (!isProductDetail)
33 {
34 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
35 }
36 else
37 {
38 var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
39 if (productObject != null)
40 {
41 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject?.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
42 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
43
44 @RenderGrid(detailPageId)
45 }
46 }
47 }
48
49 bool doNotRenderPage = false;
50
51 //Check if we are on the poduct detail page, and if there is data to render
52 ProductViewModel product = new ProductViewModel();
53 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
54 {
55 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
56 if (string.IsNullOrEmpty(product.Id))
57 {
58 doNotRenderPage = true;
59 }
60 }
61
62 //Render the page
63 if (!doNotRenderPage)
64 {
65 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
66
67 if (Pageview.IsVisualEditorMode)
68 {
69 @Model.Placeholder("dwcontent", "content", "default:true;sort:1")
70 }
71
72 <div class="@theme @itemIdentifier" @schemaOrgProp>
73 @if (isArticleListPage)
74 {
75 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\"";
76
77 <form @hx id="ArticleFacetForm">
78 @gridContent
79 </form>
80 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script>
81 <script type="module">
82 document.addEventListener('htmx:confirm', (event) => {
83 let filters = event.detail.elt.querySelectorAll('select');
84 for (var i = 0; i < filters.length; i++) {
85 let input = filters[i];
86 if (input.name && !input.value) {
87 input.name = '';
88 }
89 }
90 });
91
92 document.addEventListener('htmx:beforeOnLoad', (event) => {
93 swift.Scroll.stopIntersectionObserver();
94 });
95
96 document.addEventListener('htmx:afterOnLoad', () => {
97 swift.Scroll.hideHeadersOnScroll();
98 swift.Scroll.handleAlternativeTheme();
99 });
100 </script>
101 }
102 else
103 {
104 @gridContent
105 }
106 </div>
107
108 }
109 else
110 {
111 <div class="container">
112 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
113 </div>
114 }
115
116 if (!Model.IsCurrentUserAllowed)
117 {
118 int signInPage = GetPageIdByNavigationTag("SignInPage");
119 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
120
121 if (!Pageview.IsVisualEditorMode)
122 {
123 if (signInPage != 0)
124 {
125 if (signInPage != Model.ID)
126 {
127 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
128 }
129 else
130 {
131 if (dashboardPage != 0)
132 {
133 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
134 }
135 else
136 {
137 Dynamicweb.Context.Current.Response.Redirect("/");
138 }
139 }
140 }
141 else
142 {
143 <div class="alert alert-dark m-0" role="alert">
144 <span>@Translate("You do not have access to this page")</span>
145 </div>
146 }
147 }
148 else
149 {
150 <div class="alert alert-dark m-0" role="alert">
151 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
152 </div>
153 }
154 }
155 }
156
</main>
@if (renderAsResponsive || !renderMobile)
{
<footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
@if (footerDesktopLink != null)
{
@RenderGrid(footerDesktopLink.PageId)
}
</footer>
}
@if (renderAsResponsive || renderMobile)
{
<footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
@if (footerMobileLink != null)
{
@RenderGrid(footerMobileLink.PageId)
}
</footer>
}
@* Render any offcanvas menu here *@
@RenderSnippet("offcanvas")
@{
bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
}
@* Language selector modal *@
<div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
@* The content here comes from an external request *@
</div>
</div>
@* Favorite toast *@
<div aria-live="polite" aria-atomic="true">
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
<div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">@Translate("Favorite list updated")</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body d-flex gap-3">
<div id="favoriteNotificationToast_Image"></div>
<div id="favoriteNotificationToast_Text"></div>
</div>
</div>
</div>
</div>
@* Modal for dynamic content *@
<div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-md">
<div class="modal-content theme light" id="DynamicModalContent">
@* The content here comes from an external request *@
</div>
</div>
</div>
@* Offcanvas for dynamic content *@
<div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas">
@* The content here comes from an external request *@
</div>
@if (Model.Area.Item.GetBoolean("ShowErpDownMessage") && !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]))
{
string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
<div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">@Translate("Connection down")</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
@Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
</div>
</div>
</div>
}
@if (miniCartEnabled)
{
@* Open MiniCart when the cart is updated *@
<script type="module">
document.addEventListener('updated.swift.cart', (event) => {
let orderContext = event?.detail?.formData?.get("OrderContext");
updateCartSummary(orderContext);
@if (offcanvasMiniCartBehaviour == "2" || offcanvasMiniCartBehaviour == "3") {
<text>openMiniCartOffcanvas();</text>
}
});
</script>
if (offcanvasMiniCartBehaviour == "1" || offcanvasMiniCartBehaviour == "3")
{
@* Open MiniCart when toggle is clicked *@
<script type="module">
let miniCartToggles = document.querySelectorAll('.mini-cart-quantity');
miniCartToggles?.forEach((toggle) => {
toggle.parentElement.addEventListener('click', (event) => {
event.preventDefault();
let orderContext = toggle.dataset?.orderContext;
updateCartSummary(orderContext);
openMiniCartOffcanvas();
});
});
</script>
}
<script>
const updateCartSummary = (orderContext) => {
const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
swift.PageUpdater.UpdateFromUrlInline(event, '/Default.aspx?ID=@(cartSummaryPageId)&CartType=minicart&RequestPageID=@(Pageview.Page.ID)&OrderContext=' + orderContext +'', 'Swift_CartSummary.cshtml', dynamicOffcanvas);
};
const openMiniCartOffcanvas = () => {
const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
const miniCartOffcanvas = bootstrap.Offcanvas.getOrCreateInstance(dynamicOffcanvas);
dynamicOffcanvas.classList.add('overflow-y-auto');
if (!miniCartOffcanvas._isShown) {
miniCartOffcanvas.show();
hideActiveOffcanvases(miniCartOffcanvas);
}
};
const hideActiveOffcanvases = (miniCartOffcanvas) => {
let activeOffcanvases = document.querySelectorAll('.offcanvas.show');
activeOffcanvases?.forEach((offCanvas) => {
offCanvas = bootstrap.Offcanvas.getInstance(offCanvas);
if (offCanvas !== miniCartOffcanvas) {
offCanvas.hide();
}
});
};
</script>
}
</body>
</html>
}
else if (Pageview.IsVisualEditorMode)
{
<head>
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css" rel="stylesheet" media="all" type="text/css">
</head>
<body class="p-3">
<div class="alert alert-danger" role="alert">
@Translate("Basic Swift setup is needed!")
</div>
@if (brandingPage == null)
{
<div class="alert alert-warning" role="alert">
@Translate("Please add a Branding page and reference it in website settings")
</div>
}
@if (themesParagraphs == null)
{
<div class="alert alert-warning" role="alert">
@Translate("Please add a Themes collection page and reference it in website settings")
</div>
}
</body>
}
@functions {
void SetMetaTags()
{
//Verification Tokens
string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
//Generic Site Values
string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
//Page specific values
string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
if (!string.IsNullOrEmpty(Model.Description))
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\">");
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}\">");
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}\">");
}
else if (openGraphImage != null)
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
}
if (!string.IsNullOrEmpty(openGraphImageALT))
{
Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\">");
}
if (!string.IsNullOrEmpty(twitterCardDescription))
{
Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}/Files{Pageview.Page.TopImage}");
}
else if (twitterCardImage != null)
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
}
if (!string.IsNullOrEmpty(twitterCardImageALT))
{
Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
}
}
if (!string.IsNullOrEmpty(siteVerificationGoogle))
{
Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
}
if (!string.IsNullOrEmpty(openGraphFacebookAppID))
{
Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\">");
}
if (!string.IsNullOrEmpty(openGraphType))
{
Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\">");
}
if (!string.IsNullOrEmpty(Model.Title))
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\">");
}
if (!string.IsNullOrEmpty(twitterCardSite))
{
Pageview.Meta.AddTag("twitter:site", twitterCardSite);
}
if (!string.IsNullOrEmpty(twitterCardURL))
{
Pageview.Meta.AddTag("twitter:url", twitterCardURL);
}
if (!string.IsNullOrEmpty(twitterCardTitle))
{
Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
}
}
}