Component builder for: List card 1
Error executing template "Designs/Swift/Paragraph/Swift_ProductComponentParagraph.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Content.PageService.GetPageOrLanguage(Int32 pageId, Int32 areaId) at CompiledRazorTemplates.Dynamic.RazorEngine_41e2975136cd4f5ca2f1943a0a276bb2.Execute() in D:\dynamicweb.net\Solutions\toitoys.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductComponentParagraph.cshtml:line 7 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 @{ 4 int itemSourcePageId = Convert.ToInt32(Model.Item.GetRawValueString("ComponentSource", "0")); 5 6 var pageService = new Dynamicweb.Content.PageService(); 7 itemSourcePageId = pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID).ID; 8 } 9 10 @if (itemSourcePageId != 0) { 11 var page = Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId); 12 13 if (page != null) { 14 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 15 string itemTheme = !string.IsNullOrWhiteSpace(pageViewModel.Item.GetRawValueString("Theme")) ? " theme " + pageViewModel.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 16 17 string contentPadding = pageViewModel.Item.GetRawValueString("ContentPadding", ""); 18 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 19 contentPadding = contentPadding == "small" ? "p-2 p-md-3" : contentPadding; 20 contentPadding = contentPadding == "large" ? "p-4 p-md-5" : contentPadding; 21 22 string layout = Model.Item.GetRawValueString("Layout", "top"); 23 switch (layout) 24 { 25 case "top": 26 case "alignLeftMiddle": 27 layout = ""; 28 break; 29 case "center": 30 case "alignLeft": 31 layout = "d-flex align-items-center text-start"; 32 break; 33 } 34 35 <div class="@contentPadding @itemTheme @(layout) h-100 [email protected]()"> 36 <div class="w-100"> 37 @RenderGrid(itemSourcePageId) 38 </div> 39 </div> 40 } else if (Pageview.IsVisualEditorMode) { 41 <div class="alert alert-dark m-0" role="alert"> 42 <span>@Translate("The selected component does not exist anymore")</span> 43 </div> 44 } 45 } else if (Pageview.IsVisualEditorMode) { 46 <div class="alert alert-dark m-0" role="alert"> 47 <span>@Translate("Product component: The component will be shown here, if any")</span> 48 </div> 49 } 50
Error executing template "Designs/Swift/Paragraph/Swift_ProductComponentParagraph.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Content.PageService.GetPageOrLanguage(Int32 pageId, Int32 areaId) at CompiledRazorTemplates.Dynamic.RazorEngine_41e2975136cd4f5ca2f1943a0a276bb2.Execute() in D:\dynamicweb.net\Solutions\toitoys.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductComponentParagraph.cshtml:line 7 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 @{ 4 int itemSourcePageId = Convert.ToInt32(Model.Item.GetRawValueString("ComponentSource", "0")); 5 6 var pageService = new Dynamicweb.Content.PageService(); 7 itemSourcePageId = pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID).ID; 8 } 9 10 @if (itemSourcePageId != 0) { 11 var page = Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId); 12 13 if (page != null) { 14 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 15 string itemTheme = !string.IsNullOrWhiteSpace(pageViewModel.Item.GetRawValueString("Theme")) ? " theme " + pageViewModel.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 16 17 string contentPadding = pageViewModel.Item.GetRawValueString("ContentPadding", ""); 18 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 19 contentPadding = contentPadding == "small" ? "p-2 p-md-3" : contentPadding; 20 contentPadding = contentPadding == "large" ? "p-4 p-md-5" : contentPadding; 21 22 string layout = Model.Item.GetRawValueString("Layout", "top"); 23 switch (layout) 24 { 25 case "top": 26 case "alignLeftMiddle": 27 layout = ""; 28 break; 29 case "center": 30 case "alignLeft": 31 layout = "d-flex align-items-center text-start"; 32 break; 33 } 34 35 <div class="@contentPadding @itemTheme @(layout) h-100 [email protected]()"> 36 <div class="w-100"> 37 @RenderGrid(itemSourcePageId) 38 </div> 39 </div> 40 } else if (Pageview.IsVisualEditorMode) { 41 <div class="alert alert-dark m-0" role="alert"> 42 <span>@Translate("The selected component does not exist anymore")</span> 43 </div> 44 } 45 } else if (Pageview.IsVisualEditorMode) { 46 <div class="alert alert-dark m-0" role="alert"> 47 <span>@Translate("Product component: The component will be shown here, if any")</span> 48 </div> 49 } 50