Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetLongDescription.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_263282db37344f458e8a40a473b91b2c.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetLongDescription.cshtml:line 41
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2
3 @using Dynamicweb;
4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Configuration.AdvancedGrid.Elements;
5
6 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution;
7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend;
8
9 @{
10 string paragraphID = Pageview.CurrentParagraph.ID.ToString();
11
12 ProductDetailWidgetLongDescription _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetLongDescription", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetLongDescription>() ?? new ProductDetailWidgetLongDescription();
13 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"];
14
15 bool IsNotContentManager = false;
16 bool isVisualEditor = Pageview.IsVisualEditorMode;
17
18 if (isVisualEditor)
19 {
20 System.Web.HttpContext.Current.Session["PreviousPage"] = Pageview.Page.ID;
21 IsNotContentManager = (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser()?.Groups?.All(g => g.Name != "Content managers") ?? true);
22 }
23
24 if (ProductAndVariants != null && ProductAndVariants.ProductInfo != null && ProductAndVariants.ProductInfo.LongDescription != null)
25 {
26
27 <div id="@paragraphID" class="ProductLongDescription @_data.CssClass">
28 <div class="ProductLongDescription__header">@Translate("ProductDetailWidget.LongDescription.Header", "Productinformatie")</div>
29
30 <p>@ProductAndVariants.ProductInfo.LongDescription</p>
31 </div>
32
33 <style>
34 @_data.FontConfigurationProductName.InlineStyles
35 </style>
36
37 }
38 else
39 {
40
41 <script>console.dir(@ProductAndVariants.Template.Json)</script>
42
43 <placeholder id="@paragraphID" class="ProductLongDescription @_data.CssClass"></placeholder>
44
45 if (_data.HideTabWhenEmpty)
46 {
47 <script>
48
49 document.addEventListener('DOMContentLoaded', function () {
50
51 var Element = document.getElementById("@paragraphID");
52 console.dir(Element);
53 var parentElement = Element.closest('.content-tab');
54 console.dir(parentElement);
55 var TabElement = document.querySelector('[data-tab-target=' + parentElement.id + ']');
56 console.dir(TabElement);
57
58 @{
59 if (isVisualEditor && IsNotContentManager)
60 {
61 <text>TabElement.style.display = 'flex';</text>
62 }
63 else
64 {
65 <text>TabElement.style.display = 'none';</text>
66 }
67 }
68
69 });
70
71 </script>
72 }
73
74 }
75
76 }
77