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