Error executing template "Designs/Swift/Swift_ProductComponentEdit.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_194ff7bbe4b448c9b8ed3154320ed0ba.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() {
157 //dataLayer.push(arguments);
158 if(arguments[2] && arguments[2]?.items) {
159 dataLayer.push({ ecommerce: null });
160 dataLayer.push({
161 event: arguments[1],
162 ecommerce: arguments[2]
163 });
164 } else {
165 dataLayer.push(arguments);
166 }
167 }
168 </script>
169 @* Google tag manager *@
170 @if (!string.IsNullOrWhiteSpace(googleTagManagerID))
171 {
172 <script>
173 (function (w, d, s, l, i) {
174 w[l] = w[l] || []; w[l].push({
175 'gtm.start':
176 new Date().getTime(), event: 'gtm.js'
177 }); var f = d.getElementsByTagName(s)[0],
178 j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
179 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
180 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
181 </script>
182 }
183
184 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
185 {
186 var GoogleAnalyticsDebugMode = "";
187
188 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
189 {
190 GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
191 }
192
193 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
194 <script>
195 gtag('js', new Date());
196 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
197 </script>
198 }
199
200 @if (!string.IsNullOrWhiteSpace(customHeaderInclude))
201 {
202 @RenderPartial($"Components/Custom/{customHeaderInclude}")
203 }
204 </head>
205
206 <body class="brand @(masterTheme)">
207
208 @* Google tag manager *@
209 @if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
210 {
211 <noscript>
212 <iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
213 height="0" width="0" style="display:none;visibility:hidden"></iframe>
214 </noscript>
215 }
216
217 <div data-intersect></div>
218
219 <main id="content" @(schemaOrgType)>
220 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
221 @using System
222 @using Dynamicweb.Ecommerce.ProductCatalog
223
224
225 @{
226 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false;
227 string theme = "";
228 string contentPadding = "";
229 string gridContent = "";
230
231 if (Model.PropertyItem != null)
232 {
233 theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty;
234
235 contentPadding = Model.Item.GetRawValueString("ContentPadding", "");
236 contentPadding = contentPadding == "none" ? "p-0" : contentPadding;
237 contentPadding = contentPadding == "small" ? "p-2 p-md-3" : contentPadding;
238 contentPadding = contentPadding == "large" ? "p-4 p-md-5" : contentPadding;
239 contentPadding = contentPadding == "small-x" ? "px-2 px-md-3" : contentPadding;
240 contentPadding = contentPadding == "large-x" ? "px-4 px-md-5" : contentPadding;
241 }
242
243 if (Model.Item != null)
244 {
245 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
246 }
247
248 string viewType = Model.Item.GetRawValueString("ViewType", "3-columns");
249 string viewTypeMobile = Model.Item.GetRawValueString("ViewTypeMobile", "2-columns");
250 string mobileColumns = viewTypeMobile == "list" ? "g-col-12" : "";
251 mobileColumns = viewTypeMobile == "2-columns" ? "g-col-6" : mobileColumns;
252
253 <div class="bg-light w-100 position-relative">
254 <div class="p-5 position-fixed" style="z-index: 10">
255 <h3 class="h5">@Translate("Component builder for"): @Model.Item.GetString("Title")</h3>
256 </div>
257 <div class="container-xl d-flex flex-row align-items-center justify-content-center min-vh-100">
258 <div class="grid w-100">
259 @if (viewType == "list")
260 {
261 <div class="@mobileColumns g-col-lg-12 shadow @contentPadding @theme p-2">
262 @gridContent
263 </div>
264 }
265 @if (viewType == "2-columns")
266 {
267 <div class="@mobileColumns g-col-lg-6 shadow @contentPadding @theme p-2">
268 @gridContent
269 </div>
270 <div class="@mobileColumns g-col-lg-6 bg-black" style="opacity: 10%"></div>
271 }
272 @if (viewType == "3-columns")
273 {
274 <div class="@mobileColumns g-col-lg-4 shadow @contentPadding @theme p-2">
275 @gridContent
276 </div>
277 <div class="@mobileColumns g-col-lg-4 bg-black" style="opacity: 10%"></div>
278 <div class="@mobileColumns g-col-lg-4 bg-black" style="opacity: 10%"></div>
279 }
280 @if (viewType == "4-columns")
281 {
282 <div class="@mobileColumns g-col-lg-3 shadow @contentPadding @theme p-2">
283 @gridContent
284 </div>
285 <div class="@mobileColumns g-col-lg-3 bg-black" style="opacity: 10%"></div>
286 <div class="@mobileColumns g-col-lg-3 bg-black" style="opacity: 10%"></div>
287 <div class="@mobileColumns g-col-lg-3 bg-black" style="opacity: 10%"></div>
288 }
289 @if (viewType == "6-columns")
290 {
291 <div class="@mobileColumns g-col-lg-2 shadow @contentPadding @theme p-2">
292 @gridContent
293 </div>
294 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
295 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
296 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
297 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
298 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
299 <div class="@mobileColumns g-col-lg-2 bg-black" style="opacity: 10%"></div>
300 }
301 </div>
302 </div>
303 </div>
304 }
305
306 <script>
307 document.querySelector('#VisualEditoForcedTopHeight').style.height = 0;
308 </script>
309
310 </main>
311
312 @* Render any offcanvas menu here *@
313 @RenderSnippet("offcanvas")
314 </body>
315
316 </html>
317