Error executing template "Designs/Swift/Swift_Fonts_Collection.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_5e34972eea874363ad1bab02621815fa.ExecuteAsync()
at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2 @using Dynamicweb
3 @using Dynamicweb.Environment
4
5 @functions {
6 string GetCookieOptInPermission(string category)
7 {
8 bool categoryOrAllGranted = false;
9
10 if (CookieManager.IsCookieManagementActive)
11 {
12 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
13 var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
14 categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
15 }
16
17 return categoryOrAllGranted ? "granted" : "denied";
18 }
19
20 bool AllowTracking()
21 {
22 bool allowTracking = true;
23 if (CookieManager.IsCookieManagementActive)
24 {
25 var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
26 var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
27
28 bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
29 bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
30 bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
31
32 allowTracking = consentAtLeastOne;
33 }
34 return allowTracking;
35 }
36 }
37
38 @{
39 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
40 @* Branding Themes Fonts *@
41 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0;
42 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0;
43
44 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
45
46 string customHeaderInclude = Model.Area.Item.GetRawValueString("CustomHeaderInclude").Replace("/Files/Templates/Designs/Swift/", "");
47 if (Model.Area.Item.GetFile("CustomHeaderInclude") != null)
48 {
49 customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude").Path.Replace("/Files/Templates/Designs/Swift/", "");
50 }
51
52 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
53
54 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
55
56 var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
57 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
58 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
59
60 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
61 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
62
63 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
64 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID");
65
66 bool allowTracking = AllowTracking();
67
68 // Schema.org details for PDP
69 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
70 bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
71 bool isArticlePage = Model.ItemType == "Swift_Article";
72 string schemaOrgType = string.Empty;
73
74 if (isProductDetailsPage)
75 {
76 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
77 }
78
79 if (isArticlePage)
80 {
81 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
82 }
83 }
84
85 <!doctype html>
86 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
87 <head>
88 <!-- @swiftVersion -->
89 @* Required meta tags *@
90 <meta charset="utf-8">
91 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
92 <link rel="preload" href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" as="style">
93 <link rel="preload" href="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" as="script">
94
95 <link rel="shortcut icon" href="@favicon">
96 <link rel="apple-touch-icon" href="/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png">
97 <meta http-equiv="X-UA-Compatible" content="ie=edge">
98 <meta name="googlebot-news" content="nosnippet">
99
100 @Model.MetaTags
101
102 <title>@Model.Title</title>
103
104 @* Bootstrap + Swift stylesheet *@
105 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
106
107 @if (disableWideBreakpoints != "disableBoth")
108 {
109 <style>
110 @@media ( min-width: 1600px ) {
111 .container-xxl,
112 .container-xl,
113 .container-lg,
114 .container-md,
115 .container-sm,
116 .container {
117 max-width: 1520px;
118 }
119 }
120 </style>
121
122 if (disableWideBreakpoints != "disableUltraWideOnly")
123 {
124 <style>
125 @@media ( min-width: 1920px ) {
126 .container-xxl,
127 .container-xl,
128 .container-lg,
129 .container-md,
130 .container-sm,
131 .container {
132 max-width: 1820px;
133 }
134 }
135 </style>
136 }
137 }
138
139 @* Branding and Themes min stylesheet *@
140 <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">
141 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
142
143 <script type="module">
144 swift.Scroll.hideHeadersOnScroll();
145 swift.Scroll.handleAlternativeTheme();
146
147 //Only load if AOS
148 const aosColumns = document.querySelectorAll('[data-aos]');
149 if (aosColumns.length > 0) {
150 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
151 document.addEventListener('load.swift.assetloader', function () {
152 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
153 });
154 }
155 </script>
156
157 @* Google gtag method - always include even if it is not used for anything *@
158 <script>
159 window.dataLayer = window.dataLayer || [];
160 function gtag() { dataLayer.push(arguments); }
161 </script>
162 @* Google tag manager *@
163 @if (!string.IsNullOrWhiteSpace(googleTagManagerID))
164 {
165 <script>
166 gtag('consent', 'default', {
167 'ad_storage': 'denied',
168 'ad_user_data': 'denied',
169 'ad_personalization': 'denied',
170 'analytics_storage': 'denied'
171 });
172 </script>
173 <script>
174 (function (w, d, s, l, i) {
175 w[l] = w[l] || []; w[l].push({
176 'gtm.start':
177 new Date().getTime(), event: 'gtm.js'
178 }); var f = d.getElementsByTagName(s)[0],
179 j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
180 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
181 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
182 </script>
183 if (allowTracking)
184 {
185 string adConsent = GetCookieOptInPermission("Marketing");
186 string analyticsConsent = GetCookieOptInPermission("Statistical");
187 <script>
188 gtag('consent', 'update', {
189 'ad_storage': '@adConsent',
190 'ad_user_data': '@adConsent',
191 'ad_personalization': '@adConsent',
192 'analytics_storage': '@analyticsConsent'
193 });
194 </script>
195 }
196 }
197
198 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
199 {
200 var GoogleAnalyticsDebugMode = "";
201
202 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
203 {
204 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
205 }
206
207 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
208 <script>
209 gtag('js', new Date());
210 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
211 </script>
212 }
213
214 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
215 {
216 @RenderPartial(customHeaderInclude)
217 }
218 </head>
219
220 <body class="brand @(masterTheme)">
221
222 @* Google tag manager *@
223 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
224 {
225 <noscript>
226 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
227 height="0" width="0" style="display:none;visibility:hidden"></iframe>
228 </noscript>
229 }
230
231 <div data-intersect></div>
232
233 <main id="content" @(schemaOrgType)>
234 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
235
236
237
238 <style>
239 .font-wrapper > *{
240 font-family: var(--font-family);
241 font-weight: var(--font-weight);
242 font-style: var(--font-style);
243 }
244 </style>
245
246 <div class="container my-5">
247 <div class="grid gap-3 mb-5 pb-3 text-center border-bottom">
248 <div class="g-col-12">
249 <h1 class="h1">@Translate("Custom fonts") </h1>
250 <div class="lead">@Translate("A list of all custom fonts")</div>
251 </div>
252 </div>
253 <div class="grid gap-3">
254 @Model.Placeholder("content", "content", "default:true;sort:1")
255 </div>
256 </div>
257
258 @{
259 string cssPathEcommerceBadges = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_ecommerce_badge_styles_{Model.Area.ID}.css");
260 string cssPathTheme = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_theme_styles_{Model.Area.ID}.css");
261 string cssPathFont = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_font_styles_{Model.Area.ID}.css");
262 string cssPathBranding = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_branding_styles_{Model.Area.ID}.css");
263 string cssPathCss = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_css_styles_{Model.Area.ID}.css");
264 string cssPathCombined = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css");
265
266 string tmpPath = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_font_styles_{Model.Area.ID}.tmp");
267 Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(tmpPath), cssPathFont, false);
268 System.IO.File.Delete(tmpPath);
269
270 string combinedCss = Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathBranding);
271 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathTheme);
272 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathFont);
273 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathEcommerceBadges);
274 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathCss);
275 combinedCss = System.Text.RegularExpressions.Regex.Replace(combinedCss, @"\{([\s\S]*?)\}", match =>
276 {
277 string content = match.Groups[1].Value;
278 content = System.Text.RegularExpressions.Regex.Replace(content, @"\s+", " "); // Collapse multiple spaces to a single space
279 return "{" + content.Trim() + "}";
280 });
281 combinedCss = System.Text.RegularExpressions.Regex.Replace(combinedCss, @"\t|\n|\r", "");
282 combinedCss = combinedCss.Replace("\00a0", " "); //Re-insert spaces for content text
283 Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(combinedCss, cssPathCombined, false);
284 }
285
286 </main>
287
288 @* Render any offcanvas menu here *@
289 @RenderSnippet("offcanvas")
290 </body>
291
292 </html>
293