Stäng
Error executing template "Designs/ncnielsen/eCom/Productlist/subgrouplist.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7c5aeff78b444ee7a1e2b6e1347513b7.Execute() in D:\dynamicweb.net\Solutions\Gotcha\ncn.dw9.dynamicweb-cms.com\files\Templates\Designs\ncnielsen\eCom\Productlist\subgrouplist.cshtml:line 8
   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 @{ 2 string logoName = ""; 3 string logoAlt = ""; 4 string subgroupStartPath = ""; 5 6 Dynamicweb.Ecommerce.Products.GroupService gs = new Dynamicweb.Ecommerce.Products.GroupService(); 7 Dynamicweb.Ecommerce.Products.Group g = gs.GetGroup(GetString("Ecom:Group.ID")); 8 Dynamicweb.Ecommerce.Products.GroupCollection gc = g.ParentGroups; 9 10 if (GetLoop("Subgroups").Count() > 0) { 11 /*logoName = GetLoop("Subgroups")[0].GetString("Ecom:Group.Name").Replace(" ","_");*/ 12 logoName = gc[0].Name.Replace(" ","_"); 13 14 if (logoName.IndexOf("_") != -1) { 15 logoName = logoName.Substring(0,logoName.IndexOf("_")).ToLower().Replace(" ","_").Replace("/","_").Replace("æ","a").Replace("ø","o").Replace("å","a"); 16 subgroupStartPath = logoName + "_"; 17 logoAlt = logoName + " logo"; 18 logoName = logoName.ToLower() + "_white"; 19 logoName = logoName + ".png"; 20 } else { 21 logoName = logoName.ToLower().Replace(" ","_").Replace("/","_").Replace("æ","a").Replace("ø","o").Replace("å","a"); 22 subgroupStartPath = logoName + "_"; 23 logoAlt = logoName + " logo"; 24 logoName = logoName.ToLower() + "_white"; 25 logoName = logoName + ".png"; 26 } 27 } 28 } 29 @SnippetStart("TemplateSpecificHeader") 30 <div class="content"> 31 @if (logoName != "") { 32 if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("/files/images/ncnielsen/ecom/logos/" + logoName))) { 33 <img id="brandlogo" src='/files/images/ncnielsen/ecom/logos/@logoName' alt='@logoAlt' /> 34 } 35 } 36 <h1>@GetString("Ecom:Group.Name")</h1><span class="subheader">@GetString("Ecom:Group. ")</span></div><div id="headerImage"> 37 @{ 38 string headerImagefolderName = GetString("Ecom:Group.Name").ToLower().Replace(" ","_").Replace("/","_").Replace("æ","a").Replace("ø","o").Replace("å","a"); 39 string headerImagePath = "/files/images/ncnielsen/ecom/groups/" + subgroupStartPath + "" + headerImagefolderName + "/header.jpg"; 40 41 <img src='@headerImagePath' alt='@GetString("Ecom:Group.Name")' /> 42 } 43 </div> 44 @SnippetEnd("TemplateSpecificHeader") 45 46 <section class="section section-white section-product-list"><div class="content"><div class="filter-bar"> 47 @RenderNavigation(new { 48 template = "ecom-filtering.xslt", 49 expandmode = "all", 50 id = "ecomFiltering", 51 startlevel = "1", 52 endlevel = "5" 53 }) 54 </div><ul id="productList"> 55 @if (GetLoop("Subgroups").Count > 0) { 56 foreach (var ecomSubGroup in GetLoop("Subgroups")) { 57 string folderName = ecomSubGroup.GetString("Ecom:Group.Name").ToLower().Replace(" ","_").Replace("/","_").Replace("æ","a").Replace("ø","o").Replace("å","a"); 58 string imagePath = "/files/images/ncnielsen/ecom/groups/" + folderName + "/list.jpg"; 59 60 <li class="product"><a href="/@ecomSubGroup.GetString("Ecom:Group.Link.Clean")"><img src='@imagePath' alt='@ecomSubGroup.GetString("Ecom:Group.Name")' /><h2>@ecomSubGroup.GetString("Ecom:Group.Name")</h2> 61 @if (!string.IsNullOrWhiteSpace(@ecomSubGroup.GetString("Ecom:Group:Field.ListeLabel"))) { 62 <p>@ecomSubGroup.GetString("Ecom:Group:Field.ListeLabel"): @ecomSubGroup.GetString("Ecom:Group:Field.ListeVaerdi.Value")</p> 63 } 64 </a></li> 65 } 66 } else { 67 string folderName = GetString("Ecom:Group.Name").ToLower().Replace(" ","_").Replace("/","_").Replace("æ","ae").Replace("ø","oe").Replace("å","aa"); 68 string imagePath = "/files/images/ncnielsen/ecom/groups/" + folderName + "/list.jpg"; 69 70 <li class="product"><a href="/@GetString("Ecom:Group.Link.Clean")"><img src='@imagePath' alt='@GetString("Ecom:Group.Name")' /><h2>@GetString("Ecom:Group.Name")</h2> 71 @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Group:Field.ListeLabel"))) { 72 <p>@GetString("Ecom:Group:Field.ListeLabel"): @GetString("Ecom:Group:Field.ListeVaerdi.Value")</p> 73 } 74 </a></li> 75 } 76 </ul></div></section> 77 @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Group:Field.Headline"))) { 78 <section class="section section-greyextralight section-group-text"><div class="content"><h2><span><span>@GetString("Ecom:Group:Field.Headline")</span></span></h2> 79 @GetString("Ecom:Group.Description") 80 </div></section> 81 }