Logo
Error executing template "Designs/Dwsimple/eCom/Productlist/ProductListPageNoPagination.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_674a1bcf37f245b7b18411e32e96b985.Execute() in C:\inetpub\Dynamicweb\KBH ListeFabrik\Files\Templates\Designs\Dwsimple\eCom\Productlist\ProductListPageNoPagination.cshtml:line 383
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using System; 3 @using System.Web; 4 @using ListeFabrik.CustomModules.Classes; 5 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 6 @using System; 7 @using System.Web; 8 @using ListeFabrik.CustomModules; 9 @using ListeFabrik.CustomModules.Classes; 10 11 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 12 @using System; 13 @using System.Web; 14 @using System.Text.RegularExpressions 15 16 17 @functions{ 18 public class WrapMethods 19 { 20 //Gets the contrasting color 21 public static string getContrastYIQ(string hexcolor) 22 { 23 if (hexcolor != "") 24 { 25 hexcolor = Regex.Replace(hexcolor, "[^0-9a-zA-Z]+", ""); 26 27 int r = Convert.ToByte(hexcolor.Substring(0, 2), 16); 28 int g = Convert.ToByte(hexcolor.Substring(2, 2), 16); 29 int b = Convert.ToByte(hexcolor.Substring(4, 2), 16); 30 int yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; 31 32 if (yiq >= 128) 33 { 34 return "black"; 35 } 36 else 37 { 38 return "white"; 39 } 40 } 41 else 42 { 43 return "black"; 44 } 45 } 46 47 48 //Truncate text 49 public static string Truncate (string value, int count, bool strip=true) 50 { 51 if (strip == true){ 52 value = StripHtmlTagByCharArray(value); 53 } 54 55 if (value.Length > count) 56 { 57 value = value.Substring(0, count - 1) + "..."; 58 } 59 60 return value; 61 } 62 63 64 //Strip text from HTML 65 public static string StripHtmlTagByCharArray(string htmlString) 66 { 67 char[] array = new char[htmlString.Length]; 68 int arrayIndex = 0; 69 bool inside = false; 70 71 for (int i = 0; i < htmlString.Length; i++) 72 { 73 char let = htmlString[i]; 74 if (let == '<') 75 { 76 inside = true; 77 continue; 78 } 79 if (let == '>') 80 { 81 inside = false; 82 continue; 83 } 84 if (!inside) 85 { 86 array[arrayIndex] = let; 87 arrayIndex++; 88 } 89 } 90 return new string(array, 0, arrayIndex); 91 } 92 93 //Make the correct count of columns 94 public static string ColumnMaker(int Col, string ScreenSize) 95 { 96 string Columns = ""; 97 98 switch (Col) 99 { 100 case 1: 101 Columns = "col-"+ScreenSize+"-12"; 102 break; 103 104 case 2: 105 Columns = "col-"+ScreenSize+"-6"; 106 break; 107 108 case 3: 109 Columns = "col-"+ScreenSize+"-4"; 110 break; 111 112 case 4: 113 Columns = "col-"+ScreenSize+"-3"; 114 break; 115 116 default: 117 Columns = "col-"+ScreenSize+"-3"; 118 break; 119 } 120 121 return Columns; 122 } 123 124 125 private string Custom(string firstoption, string secondoption) 126 { 127 if (firstoption == "custom") 128 { 129 return secondoption; 130 } 131 else 132 { 133 return firstoption; 134 } 135 } 136 } 137 } 138 139 140 @helper GetProductList(dynamic Loop, int ColMD = 3, int ColSM = 3, int ColXS = 1) 141 { 142 var area = Dynamicweb.Services.Areas.GetArea(Pageview.Area.ID); 143 144 string searchWords = HttpContext.Current.Request.QueryString["search"]; 145 bool isSearch = (!string.IsNullOrWhiteSpace(searchWords)) ? true : false; 146 147 int Count = 0; 148 149 string ColumnsMD = WrapMethods.ColumnMaker(ColMD, "md"); 150 string ColumnsSM = WrapMethods.ColumnMaker(ColSM, "sm"); 151 string ColumnsXS = WrapMethods.ColumnMaker(ColXS, "xs"); 152 153 154 foreach (LoopItem product in Loop) 155 { 156 var standardPrice = product.GetDouble("Ecom:Product.DBPrice"); 157 var customerPrice = product.GetDouble("Ecom:Product.Price.Price"); 158 string perUnitText = "/" + product.GetString("Ecom:Product:Field.ProductUnit"); 159 bool soldByLength = perUnitText == "/M"; 160 var currency = product.GetString("Ecom:Product.Price.Currency.Code"); 161 string Image = product.GetString("Ecom:Product:Field.MainProductImage"); 162 string Picto = product.GetString("Ecom:Product:Field.ProductPictogram"); 163 string GroupLink = product.GetString("Ecom:Product.LinkGroup.Clean"); 164 string Name = product.GetString("Ecom:Product.Name"); 165 string Description = product.GetString("Ecom:Product.ShortDescription"); 166 string Discount = product.GetString("Ecom:Product.Discount.Price"); 167 string Price = product.GetString("Ecom:Product.Price"); 168 string RawPrice = product.GetString("Ecom:Product.Price.PricePIP"); 169 string Filters = product.GetString("Ecom:Product:Field.FilterValues"); 170 string filterClasses = string.Empty; 171 string imagealttext = product.GetString("Ecom:Product:Field.ProductImageAltText"); 172 173 if (!string.IsNullOrWhiteSpace(Filters)) 174 { 175 filterClasses = "filter-" + Filters.Trim().Replace(",", " filter-"); 176 } 177 178 if (isSearch) 179 { 180 // If the primary group is not in the current shop, we have to take the group link to the first group that's in the shop 181 // Otherwise DW takes the first group regardless if it belongs to the area or not 182 bool isPrimaryGroupInShop = false; 183 184 string primaryGroupID = product.GetString("Ecom:Product.PrimaryGroupID"); 185 186 if (!string.IsNullOrEmpty(primaryGroupID)) 187 { 188 var primaryGroup = Dynamicweb.Ecommerce.Products.Group.GetGroupById(primaryGroupID); 189 isPrimaryGroupInShop = primaryGroup.Shops.Any(x => x.Id == area.EcomShopId); 190 } 191 192 if (!isPrimaryGroupInShop) 193 { 194 foreach (var loopGroup in product.GetLoop("AssociatedGroups")) 195 { 196 var group = Dynamicweb.Ecommerce.Products.Group.GetGroupById(loopGroup.GetString("Ecom:Group.ID")); 197 if (group.ShopId == area.EcomShopId) 198 { 199 GroupLink = loopGroup.GetString("Ecom:Group.Link.Clean") + "&ProductID=" + product.GetString("Ecom:Product.ID.UrlEncoded"); 200 break; 201 } 202 } 203 } 204 } 205 206 <div class="productlist grid-item @ColumnsMD @ColumnsSM @ColumnsXS @filterClasses" 207 data-name="@HttpUtility.HtmlEncode(Name.ToLower())" 208 data-price="@RawPrice" 209 data-filter-classes="@filterClasses"> 210 211 <div class="boxproduct wp-block product"> 212 <div class="listproductright"> 213 <a href="@GroupLink" title="@HttpUtility.HtmlEncode(Name)"> 214 <figure style="" class="productfigure"> 215 @if (!string.IsNullOrEmpty(Image)) 216 { 217 <img alt="@HttpUtility.HtmlEncode(imagealttext)" src="@PIMCommerceUtilities.GetPerfionImageUrl(Image,"100x100")" class="img-responsive img-center"> 218 } 219 </figure> 220 @if (!string.IsNullOrEmpty(Picto)) 221 { 222 <span class="product-picto"><img alt="" src="@PIMCommerceUtilities.GetPerfionImageUrl(Picto, "50x50")" /></span> 223 } 224 </a> 225 </div> 226 <div class="extracolumn"> 227 <h2 class="product-title"><a href="@GroupLink">@Name.Replace("/", " / ")</a></h2> 228 <p>@Translate("Product number", "Product number"): <span>@product.GetString("Ecom:Product.Number")</span></p> 229 </div> 230 <div class="listproductleft wp-block-footer"> 231 @if (customerPrice < standardPrice) 232 { 233 <span class="productprice price pull-right" style=" font-size: 16px !important" content="@product.GetString("Ecom:Product.Price.Price").Replace(",", ".")"><strong>@product.GetString("Ecom:Product.Price.Price")&nbsp;@currency@perUnitText</strong></span><span>&nbsp;&nbsp;</span> 234 <span class="productpricebr"></span> 235 <p class="productoldprice price" style="margin-top: -15px !important; padding-top: 0px !important; color: #AAAAAA !important; font-size: 12px !important; text-align: right; text-decoration: line-through">@standardPrice.ToString("F")&nbsp;@currency@perUnitText</p> 236 } 237 else 238 { 239 <span class="productprice price pull-right" style="font-size: 16px !important" content="@product.GetString("Ecom:Product.Price.Price").Replace(",", ".")"><strong>@product.GetString("Ecom:Product.Price.Price")&nbsp;@currency@perUnitText</strong></span><span>&nbsp;&nbsp;</span> 240 } 241 </div> 242 </div> 243 244 </div> 245 246 Count++; 247 248 if (Count == ColMD) 249 { 250 <div class="row"></div> 251 Count = 0; 252 } 253 } 254 } 255 256 257 @{ 258 string searchWords = HttpContext.Current.Request.QueryString["search"]; 259 bool isSearch = (!string.IsNullOrWhiteSpace(searchWords)) ? true : false; 260 string grouplink = ""; 261 262 if (!string.IsNullOrWhiteSpace(GetString("Ecom:ProductList:Page.GroupID"))) 263 { 264 grouplink = "/Default.aspx?ID=" + GetString("Ecom:ProductList:Page.ID") + "&amp;GroupID=" + GetString("Ecom:ProductList:Page.GroupID"); 265 } 266 else 267 { 268 grouplink = "/Default.aspx?ID=" + GetString("Ecom:ProductList:Page.ID") + "&amp;search=" + GetString("Ecom:ProductList:Search.Query"); 269 } 270 271 var products = GetLoop("Products"); 272 var distinctFilters = (from LoopItem product in products select product.GetString("Ecom:Product:Field.FilterValues").Split(',')).SelectMany(x => x).Distinct(); 273 } 274 275 <div class="row"> 276 <div class="col-md-4 col-sm-4 col-xs-4"> 277 @if (isSearch) 278 { 279 <h3 class="section-title">@searchWords</h3> 280 } 281 else 282 { 283 <h1 class="section-title"> 284 @GetString("Ecom:ProductList:Page.GroupName") 285 </h1> 286 <h2 class="section-title">@GetString("Ecom:Group:Field.WebCategoryTextH2.Value")</h2> 287 if (!string.IsNullOrEmpty(GetString("Ecom:Group:Field.CategoryImage.Value"))) 288 { 289 <img src="@PIMCommerceUtilities.GetPerfionImageUrl(GetString("Ecom:Group:Field.CategoryImage.Value"), "600x200")" alt="@GetString("Ecom:Group:Field.WebCategoryAltText.Value")" class="group-img img-center" /> 290 } 291 } 292 </div> 293 294 <div class="col-md-4 col-sm-4 col-xs-4 hidden-xs"></div> 295 296 <div class="col-md-4 col-sm-4 col-xs-4 pull-right"> 297 <div class="btn-group pull-right hidden-xs" style="" id="viewbtns"> 298 <button type="button" class="btn btn-xs btn-three" onclick="ListView(true)"><span class="glyphicon glyphicon-th-list"></span></button> 299 <button type="button" class="btn btn-xs btn-three" onclick="BoxView(true)"><span class="glyphicon glyphicon-th"></span></button> 300 </div> 301 <div class="pull-right"> 302 <div class="btn-group"> 303 <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> 304 @Translate("Sort by", "Sort by") <span class="caret"></span> 305 </button> 306 <ul class="dropdown-menu dropdown-menu-right" role="menu"> 307 <li><a class="pill-left sort-btn" data-sortby="price" data-sortorder="asc">@Translate("Price low-high", "Price low-high")</a></li> 308 <li><a class="pill-left sort-btn" data-sortby="price" data-sortorder="desc">@Translate("Price high-low", "Price high-low")</a></li> 309 </ul> 310 </div> 311 &nbsp;&nbsp; 312 </div> 313 </div> 314 </div> 315 316 317 @if (!isSearch) 318 { 319 <div class="row"> 320 <div class="col-md-12 group-description"> 321 <article> 322 <p> 323 @GetString("Ecom:Group.Description") 324 </p> 325 </article> 326 </div> 327 </div> 328 329 <div class="row"> 330 <div class="col-md-12"> 331 <ul class="filters-list"> 332 @foreach (var feature in GetLoop("FilterFeatures")) 333 { 334 int nbFilters = (from LoopItem option in feature.GetLoop("Options") select option.GetString("Option.Value")).Distinct().Count(); 335 336 if (nbFilters > 1) 337 { 338 var options = feature.GetLoop("Options"); 339 var applicableFilters = options.Count(x => distinctFilters.Contains(x.GetString("Option.Value"))); 340 341 if (applicableFilters > 1) 342 { 343 <li class="filter button-group" data-filter-group="@feature.GetString("Feature.name")"> 344 <h4>@feature.GetString("Feature.caption")</h4> 345 <select class="filter-options-list"> 346 <option class="filter-option is-checked" data-filter=""> 347 @Translate("AllFilters", "All") 348 </option> 349 @foreach (var option in options) 350 { 351 if (distinctFilters.Contains(option.GetString("Option.Value"))) 352 { 353 <option class="filter-option" data-filter=".filter-@option.GetString("Option.Value")"> 354 @option.GetString("Option.Label") 355 </option> 356 } 357 } 358 </select> 359 </li> 360 } 361 } 362 } 363 </ul> 364 365 </div> 366 </div> 367 } 368 369 <div class="row grid main-product-list"> 370 @GetProductList(products, 4) 371 </div> 372 373 374 <script> 375 @{ 376 string banner = string.Empty; 377 378 if (!isSearch) 379 { 380 if (string.IsNullOrEmpty(GetString("Ecom:Group:Field.Banner"))) 381 { 382 // if no banner, we take the parent group banner 383 var parents = Dynamicweb.Ecommerce.Products.Group.GetGroupById(GetString("Ecom:Group.ID")).ParentGroups; 384 if (parents.Count > 0) 385 { 386 string parentBanner = parents[0].ProductGroupFieldValues.GetProductGroupFieldValue("CategoryImage").Value.ToString(); 387 if (!string.IsNullOrEmpty(parentBanner)) 388 { 389 banner = PIMCommerceUtilities.GetPerfionImageUrl(parentBanner); 390 } 391 } 392 } 393 else 394 { 395 banner = PIMCommerceUtilities.GetPerfionImageUrl(GetString("Ecom:Group:Field.CategoryImage")); 396 } 397 } 398 } 399 400 ProductListSettings = { 401 GroupLink: '@grouplink', 402 GroupBanner: '@banner', 403 EcommerceProductListForm: '@Pageview.Area.Item["EcommerceProductListForm"].ToString()', 404 SortSettings: { sortBy: 'original-order' }, 405 IsSearch: @isSearch.ToString().ToLower() 406 }; 407 </script> 408 409 <script src="/Files/Templates/Designs/Dwsimple/js/pages/productlist.js" defer="defer"></script> 410 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 411 <script src="/Files/Templates/Designs/Dwsimple/js/vendor/readmore.js"></script> 412 413 <script> 414 $('article').readmore({ 415 speed: 500, 416 collapsedHeight: 60, 417 heightMargin: 16, 418 moreLink: '<a class="btn btn btn-sm btn-dw-secondary" href="#">@Translate("ReadMore", "Læs mere")</a>', 419 lessLink: '<a class="btn btn btn-sm btn-dw-secondary" href="#">@Translate("Close", "Luk")</a>', 420 }); 421 </script>

Kontakt os

 

Sociale links

  

 

Nyhedsbrev

Tilmeld dig hvis du vil modtage vores nyhedsbrev.

 
Cookies

Dette website bruger cookies til statistik og til at levere den bedste brugeroplevelse til dig
Du kan altid slette cookies i din browsers indstillinger.  Læs mere

Accepter ikke cookies Accepter kun funktions cookies Accepter alle cookies