BESTILLING AF KATALOG
Udfyld formularen og få tilsendt gratis Spring 2024 katalog.
Sendes kun til danske adresser.
Error executing template "Designs/Swift/Paragraph/Swift_Text.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_48b37c2c3ea444d887c3c87a78d074ea.<>c__DisplayClass0_0.<RenderBody>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_Text.cshtml:line 106 at CompiledRazorTemplates.Dynamic.RazorEngine_48b37c2c3ea444d887c3c87a78d074ea.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_Text.cshtml:line 32 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 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 string layout = Model.Item.GetRawValueString("Layout", "text-start"); 6 layout = layout == "alignLeft" ? "align-items-start text-start" : layout; 7 layout = layout == "alignCenter" ? "align-items-center text-center" : layout; 8 layout = layout == "alignRight" ? "align-items-end text-end" : layout; 9 layout = layout == "alignLeftMiddle" ? "align-items-start text-start justify-content-center" : layout; 10 11 string contentPadding = Model.Item.GetRawValueString("ContentPadding", ""); 12 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 13 contentPadding = contentPadding == "small" ? "p-3 p-md-3" : contentPadding; 14 contentPadding = contentPadding == "large" ? "p-5 p-md-5" : contentPadding; 15 16 //Backward compatibility (Vertical align) 17 string verticalAlign = ""; 18 if (!string.IsNullOrEmpty(Model.Item.GetString("verticalAlign"))) { 19 verticalAlign = verticalAlign == "vertical-align-top" ? "justify-content-start" : verticalAlign; 20 verticalAlign = verticalAlign == "vertical-align-center" ? "justify-content-center" : verticalAlign; 21 verticalAlign = verticalAlign == "vertical-align-bottom" ? "justify-content-end" : verticalAlign; 22 } 23 24 string maxWidth = Model.Item.GetRawValueString("TextReadability", "max-width-on"); 25 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth; 26 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth; 27 28 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 29 } 30 31 <div class="h-100 position-relative d-flex flex-column mb-0-last-child @contentPadding @verticalAlign @(layout)@(theme) item_@Model.Item.SystemName.ToLower()"> 32 @{@RenderBody(maxWidth)} 33 </div> 34 35 @helper RenderBody(string maxWidth) 36 { 37 Dynamicweb.Frontend.LinkViewModel link1 = new Dynamicweb.Frontend.LinkViewModel(); 38 Dynamicweb.Frontend.LinkViewModel link2 = new Dynamicweb.Frontend.LinkViewModel(); 39 40 string linkType1 = Model.Item.GetRawValueString("LinkType", "page"); 41 string linkType2 = Model.Item.GetRawValueString("LinkType2", "page2"); 42 43 if (linkType1 == "page" && Model.Item.GetLink("ButtonLink") != null) 44 { 45 link1 = Model.Item.GetLink("ButtonLink"); 46 } 47 48 if (linkType2 == "page2" && Model.Item.GetLink("ButtonLink2") != null) 49 { 50 link2 = Model.Item.GetLink("ButtonLink2"); 51 } 52 53 if (linkType1 == "product-group") 54 { 55 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink"); 56 IList<string> groupIds = new List<string> { }; 57 58 if (selectedGroups != null) 59 { 60 foreach (var fromGroup in selectedGroups) 61 { 62 groupIds.Add(fromGroup.Id); 63 } 64 } 65 66 link1 = new Dynamicweb.Frontend.LinkViewModel() 67 { 68 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds) 69 }; 70 } 71 72 if (linkType2 == "product-group2") 73 { 74 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink2"); 75 IList<string> groupIds = new List<string> { }; 76 77 if (selectedGroups != null) 78 { 79 foreach (var fromGroup in selectedGroups) 80 { 81 groupIds.Add(fromGroup.Id); 82 } 83 } 84 85 link2 = new Dynamicweb.Frontend.LinkViewModel() 86 { 87 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(), 88 IsExternal = false 89 }; 90 } 91 92 if (linkType1 == "product") 93 { 94 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink"); 95 IList<string> productIds = new List<string> { }; 96 97 if (products != null) 98 { 99 foreach (var product in products.Products) 100 { 101 productIds.Add(product.Id); 102 } 103 } 104 105 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 106 string productLink = products.Products.FirstOrDefault().GetProductLink(GetPageIdByNavigationTag("Shop"), false); 107 productLink = productIds.Count != 1 ? "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&" + productParameter + "=" + string.Join(",", productIds).Trim() : productLink; 108 109 link1 = new Dynamicweb.Frontend.LinkViewModel() 110 { 111 Url = productLink 112 }; 113 } 114 115 if (linkType2 == "product2") 116 { 117 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink2"); 118 IList<string> productIds = new List<string> { }; 119 120 if (products != null) 121 { 122 foreach (var product in products.Products) 123 { 124 productIds.Add(product.Id); 125 } 126 } 127 128 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 129 string productLink = products.Products.FirstOrDefault().GetProductLink(GetPageIdByNavigationTag("Shop"), false); 130 productLink = productIds.Count != 1 ? "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&" + productParameter + "=" + string.Join(",", productIds).Trim() : productLink; 131 132 link2 = new Dynamicweb.Frontend.LinkViewModel() 133 { 134 Url = productLink, 135 IsExternal = false 136 }; 137 } 138 139 if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) && !Model.Item.GetBoolean("HideTitle")) 140 { 141 string titleColor = Model.Item.GetString("TitleColor", "text-inherit"); 142 string titleOpacity = Model.Item.GetString("TitleOpacity", "opacity-100"); 143 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 144 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 145 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {titleColor} {titleOpacity}{maxWidth} mb-3\">"; 146 string headingLevelStop = $"</{headingLevel}>"; 147 148 @headingLevelStart 149 @Model.Item.GetString("Title") 150 @headingLevelStop 151 } 152 153 if (!string.IsNullOrEmpty(Model.Item.GetString("Lead"))) 154 { 155 string subtitleColor = Model.Item.GetString("SubtitleColor", "text-inherit"); 156 string subtitleOpacity = Model.Item.GetString("SubtitleOpacity", "opacity-100"); 157 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 158 159 <p class="@subtitleFontSize @subtitleColor @subtitleOpacity lead mb-3@(maxWidth)"> 160 @Model.Item.GetString("Lead") 161 </p> 162 } 163 164 if (!string.IsNullOrEmpty(Model.Item.GetString("Text"))) 165 { 166 string textColor = Model.Item.GetString("TextColor", "text-inherit"); 167 string textOpacity = Model.Item.GetString("TextOpacity", "opacity-100"); 168 169 <div class="mb-0-last-child @textColor @(textOpacity)@(maxWidth)"> 170 @Model.Item.GetString("Text") 171 </div> 172 } 173 174 if (link1 != null && !string.IsNullOrEmpty(link1.Url) || link2 != null && !string.IsNullOrEmpty(link2.Url)) 175 { 176 string target1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "target=\"_blank\"" : ""; 177 string target2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "target=\"_blank\"" : ""; 178 string rel1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "rel=\"noopener\"" : ""; 179 string rel2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "rel=\"noopener\"" : ""; 180 string buttonLabel1 = Model.Item.GetString("ButtonLabel", string.Empty); 181 string buttonLabel2 = Model.Item.GetString("ButtonLabel2", string.Empty); 182 string buttonStyle1 = Model.Item.GetRawValueString("ButtonStyle", ""); 183 buttonStyle1 = buttonStyle1 == "primary" ? "btn-primary " : buttonStyle1; 184 buttonStyle1 = buttonStyle1 == "secondary" ? "btn-secondary " : buttonStyle1; 185 buttonStyle1 = buttonStyle1 == "link" ? "btn-link" : buttonStyle1; 186 string buttonStyle2 = Model.Item.GetRawValueString("ButtonStyle2", ""); 187 buttonStyle2 = buttonStyle2 == "primary" ? "btn-primary " : buttonStyle2; 188 buttonStyle2 = buttonStyle2 == "secondary" ? "btn-secondary " : buttonStyle2; 189 buttonStyle2 = buttonStyle2 == "link" ? "btn-link" : buttonStyle2; 190 string stretchedLink1 = Model.Item.GetRawValueString("StretchedLink", "column-not-clickable"); 191 string stretchedLink2 = Model.Item.GetRawValueString("StretchedLink2", "column-not-clickable"); 192 string stretchedLinkClass = stretchedLink1 == "column-clickable" && string.IsNullOrEmpty(link2.Url) && string.IsNullOrEmpty(buttonLabel2) ? "stretched-link" : string.Empty; 193 string stretchedLinkClass2 = stretchedLink2 == "column-clickable" && string.IsNullOrEmpty(link1.Url) && string.IsNullOrEmpty(buttonLabel1) ? "stretched-link" : string.Empty; 194 string alignmentClass = string.Empty; 195 196 if (Model.Item.GetString("Layout") == "alignCenter") 197 { 198 alignmentClass = " justify-content-center"; 199 } 200 <div class="d-flex flex-wrap gap-3 mt-3@(alignmentClass)"> 201 202 @if (link1 != null && !string.IsNullOrEmpty(link1.Url)) 203 { 204 if (!string.IsNullOrEmpty(buttonLabel1)) 205 { 206 <a href="@link1.Url" @target1 @rel1 class="text-nowrap btn @(buttonStyle1)@(stretchedLinkClass)">@buttonLabel1</a> 207 } 208 else 209 { 210 <a href="@link1.Url" @target1 @rel1 class="@(stretchedLinkClass)"> 211 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 212 </a> 213 } 214 } 215 216 @if (link2 != null && !string.IsNullOrEmpty(link2.Url)) 217 { 218 if (!string.IsNullOrEmpty(buttonLabel2)) 219 { 220 <a href="@link2.Url" @target2 @rel2 class="text-nowrap btn @(buttonStyle2)@(stretchedLinkClass2)">@buttonLabel2</a> 221 } 222 else 223 { 224 <a href="@link2.Url" @target2 @rel2 class="@(stretchedLinkClass2)"> 225 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 226 </a> 227 } 228 } 229 </div> 230 } 231 } 232