Last ned bilder

DIN
Error executing template "Designs/Swift/Paragraph/CustomPublicationDownload.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_e97cef0b74674299af93ebb301fdb8ce.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)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 6 @{ 7 ProductViewModel product = null; 8 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 9 { 10 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 11 } 12 else if (Pageview.Page.Item["DummyProduct"] != null) 13 { 14 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 15 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 16 17 if (productList?.Products is object) 18 { 19 product = productList.Products[0]; 20 } 21 } 22 23 string uniqueId = $"{product?.Id}_{product?.VariantId.Replace(".", "_")}_{Pageview.CurrentParagraph.ID}"; 24 25 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", string.Empty); 26 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 27 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 28 horizontalAlign = horizontalAlign == "full" ? string.Empty : horizontalAlign; 29 30 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 31 32 switch (buttonSize) 33 { 34 case "small": 35 buttonSize = " btn-sm"; 36 break; 37 case "regular": 38 buttonSize = string.Empty; 39 break; 40 case "large": 41 buttonSize = " btn-lg"; 42 break; 43 } 44 45 string iconPath = "/Files/Icons/"; 46 47 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : string.Empty; 48 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : string.Empty; 49 string icon = Model.Item.GetRawValueString("Icon", iconPath + "printer.svg"); 50 string label = !icon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(icon)}</span>" : string.Empty; 51 label += !icon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : string.Empty; 52 label += !Model.Item.GetBoolean("HideButtonText") && !string.IsNullOrEmpty(Model.Item.GetString("Title")) ? Model.Item.GetString("Title") : string.Empty; 53 } 54 55 @if (product is object) 56 { 57 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 58 var publication = Model.Item.GetRawValueString("Publication", ""); 59 60 @if (!string.IsNullOrEmpty(publication)) 61 { 62 63 var pageObj = Dynamicweb.Content.Services.Pages.GetPage(Convert.ToInt32(publication)); 64 65 if (pageObj is object) 66 { 67 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 68 <form target="_blank" action="/Default.aspx?ID=@(pageObj.ID)" method="post" id="DownloadPublicationModalForm@(uniqueId)"> 69 <input type="hidden" name="mainproductid" value="@product.Id"> 70 <input type="hidden" name="print" value="true"> 71 72 @if (!string.IsNullOrEmpty(product.VariantId)) 73 { 74 <input type="hidden" name="VariantId" value="@product.VariantId"> 75 } 76 77 <button type="button" onclick="GetPublication(event)" class="btn btn-primary @(buttonSize) @flexFill @theme" style="white-space: nowrap" title="@Model.Item.GetString("Title")" id="DownloadPublication@(uniqueId)"> 78 @if (!Model.Item.GetBoolean("HideButtonText")) 79 { 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @label 82 </span> 83 } 84 else 85 { 86 @label 87 } 88 </button> 89 </form> 90 </div> 91 } 92 93 } 94 95 96 <script> 97 const GetPublication = (e) => { 98 const clickedButton = e.currentTarget; 99 const form = clickedButton.closest('form'); 100 101 form.closest('form').submit(); 102 103 commentField = form.querySelector('textarea[name="DealerComment"]'); 104 105 if (commentField) { 106 commentField.value = ""; 107 } 108 }; 109 </script> 110 } 111 else if (Pageview.IsVisualEditorMode) 112 { 113 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 114 <button type="button" class="btn btn-primary @(buttonSize) @flexFill" data-bs-toggle="modal" data-bs-target="#DownloadPublicationModal@(uniqueId)" style="white-space: nowrap" title="@Model.Item.GetString("Title")" id="DownloadPublication@(uniqueId)"> 115 @if (!Model.Item.GetBoolean("HideButtonText")) 116 { 117 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 118 @label 119 </span> 120 } 121 else 122 { 123 @label 124 } 125 </button> 126 </div> 127 } 128
By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing