Luk
Error executing template "Designs/ncnielsen/eCom/Productlist/subgrouplist.cshtml"
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at CompiledRazorTemplates.Dynamic.RazorEngine_ccde4bbd633a44489feea30bf421f4c0.Execute() in D:\dynamicweb.net\Solutions\Gotcha\ncn.dw9.dynamicweb-cms.com\files\Templates\Designs\ncnielsen\eCom\Productlist\subgrouplist.cshtml:line 13
   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 @{ 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 { 12 /*logoName = GetLoop("Subgroups")[0].GetString("Ecom:Group.Name").Replace(" ","_");*/ 13 logoName = gc[0].Name.Replace(" ", "_"); 14 15 if (logoName.IndexOf("_") != -1) 16 { 17 logoName = logoName.Substring(0, logoName.IndexOf("_")).ToLower().Replace(" ", "_").Replace("/", "_").Replace("æ", "a").Replace("ø", "o").Replace("å", "a"); 18 subgroupStartPath = logoName + "_"; 19 logoAlt = logoName + " logo"; 20 logoName = logoName.ToLower() + "_white"; 21 logoName = logoName + ".png"; 22 } 23 else 24 { 25 logoName = logoName.ToLower().Replace(" ", "_").Replace("/", "_").Replace("æ", "a").Replace("ø", "o").Replace("å", "a"); 26 subgroupStartPath = logoName + "_"; 27 logoAlt = logoName + " logo"; 28 logoName = logoName.ToLower() + "_white"; 29 logoName = logoName + ".png"; 30 } 31 } 32 } 33 @SnippetStart("TemplateSpecificHeader") 34 <div class="content"> 35 @if (logoName != "") 36 { 37 if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("/files/images/ncnielsen/ecom/logos/" + logoName))) 38 { 39 <img id="brandlogo" src='/files/images/ncnielsen/ecom/logos/@logoName' alt='@logoAlt' /> 40 } 41 } 42 <h1>@GetString("Ecom:Group.Name")</h1><span class="subheader">@GetString("Ecom:Group. ")</span> 43 </div><div id="headerImage"> 44 @{ 45 string headerImagefolderName = GetString("Ecom:Group.Name").ToLower().Replace(" ", "_").Replace("/", "_").Replace("æ", "a").Replace("ø", "o").Replace("å", "a"); 46 string headerImagePath = "/files/images/ncnielsen/ecom/groups/" + subgroupStartPath + "" + headerImagefolderName + "/header.jpg"; 47 48 <img src='@headerImagePath' alt='@GetString("Ecom:Group.Name")' /> 49 } 50 </div> 51 @SnippetEnd("TemplateSpecificHeader") 52 53 <section class="section section-white section-product-list"> 54 <div class="content"> 55 <div class="filter-bar"> 56 @RenderNavigation(new 57 { 58 template = "ecom-filtering.xslt", 59 expandmode = "all", 60 id = "ecomFiltering", 61 startlevel = "1", 62 endlevel = "5" 63 }) 64 </div><ul id="productList"> 65 @if (GetLoop("Subgroups").Count > 0) 66 { 67 foreach (var ecomSubGroup in GetLoop("Subgroups")) 68 { 69 string folderName = ecomSubGroup.GetString("Ecom:Group.Name").ToLower().Replace(" ", "_").Replace("/", "_").Replace("æ", "a").Replace("ø", "o").Replace("å", "a"); 70 string imagePath = "/files/images/ncnielsen/ecom/groups/" + folderName + "/list.jpg"; 71 string link = ecomSubGroup.GetString("Ecom:Group.Link.Clean"); 72 73 if (!string.IsNullOrWhiteSpace(ecomSubGroup.GetString("Ecom:Group:Field.ShadowGroupLink"))) 74 { 75 link = ecomSubGroup.GetString("Ecom:Group:Field.ShadowGroupLink"); 76 } 77 78 <li class="product"> 79 <a href="@link"> 80 <img src='@imagePath' alt='@ecomSubGroup.GetString("Ecom:Group.Name")' /><h2>@ecomSubGroup.GetString("Ecom:Group.Name")</h2> 81 @if (!string.IsNullOrWhiteSpace(@ecomSubGroup.GetString("Ecom:Group:Field.ListeLabel"))) 82 { 83 <p>@ecomSubGroup.GetString("Ecom:Group:Field.ListeLabel"): @ecomSubGroup.GetString("Ecom:Group:Field.ListeVaerdi.Value")</p> 84 } 85 </a> 86 </li> 87 } 88 } 89 else 90 { 91 string folderName = GetString("Ecom:Group.Name").ToLower().Replace(" ", "_").Replace("/", "_").Replace("æ", "ae").Replace("ø", "oe").Replace("å", "aa"); 92 string imagePath = "/files/images/ncnielsen/ecom/groups/" + folderName + "/list.jpg"; 93 string link = GetString("Ecom:Group.Link.Clean"); 94 95 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Group:Field.ShadowGroupLink"))) 96 { 97 link = GetString("Ecom:Group:Field.ShadowGroupLink"); 98 } 99 100 <li class="product"> 101 <a href="@link"> 102 <img src='@imagePath' alt='@GetString("Ecom:Group.Name")' /><h2>@GetString("Ecom:Group.Name")</h2> 103 @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Group:Field.ListeLabel"))) 104 { 105 <p>@GetString("Ecom:Group:Field.ListeLabel"): @GetString("Ecom:Group:Field.ListeVaerdi.Value")</p> 106 } 107 </a> 108 </li> 109 } 110 </ul> 111 </div> 112 </section> 113 @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Group:Field.Headline"))) 114 { 115 <section class="section section-greyextralight section-group-text"> 116 <div class="content"> 117 <h2><span><span>@GetString("Ecom:Group:Field.Headline")</span></span></h2> 118 @GetString("Ecom:Group.Description") 119 </div> 120 </section> 121 }