protected void CreateChildMenu(CategoryCollection breadCrumb, int rootCategoryId, Category currentCategory, int level) { int padding = level++ *15; foreach (var category in CategoryManager.GetAllCategories(rootCategoryId)) { var link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryUrl(category.CategoryId); if (currentCategory != null && currentCategory.CategoryId == category.CategoryId) { link.CssClass = "active"; } else { link.CssClass = "inactive"; } link.HyperLink.NavigateUrl = categoryURL; link.HyperLink.Text = Server.HtmlEncode(category.Name); if (padding > 0) { link.LiLeftMargin = padding.ToString(); } for (int i = 0; i <= breadCrumb.Count - 1; i++) { if (breadCrumb[i].CategoryId == category.CategoryId) { CreateChildMenu(breadCrumb, category.CategoryId, currentCategory, level); } } } }
protected void CreateChildMenu(List<Category> breadCrumb, int rootCategoryId, Category currentCategory, int level) { int padding = level++ * 15; foreach (var category in this.CategoryService.GetAllCategoriesByParentCategoryId(rootCategoryId)) { var link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryUrl(category); if (currentCategory != null && currentCategory.CategoryId == category.CategoryId) link.CssClass = "active"; else link.CssClass = "inactive"; link.HyperLink.NavigateUrl = categoryURL; string catName = string.Empty; if (this.SettingManager.GetSettingValueBoolean("Display.Products.ShowCategoryProductNumber")) { //display category name with assigned products number int numberOfProducts = GetNumberOfProducts(category, this.SettingManager.GetSettingValueBoolean("Display.Products.ShowCategoryProductNumber.IncludeSubCategories")); catName = string.Format("{0} ({1})", category.LocalizedName, numberOfProducts); } else { //display only category name catName = category.LocalizedName; } link.HyperLink.Text = Server.HtmlEncode(catName); if (padding > 0) link.LiLeftMargin = padding.ToString(); for (int i = 0; i <= breadCrumb.Count - 1; i++) if (breadCrumb[i].CategoryId == category.CategoryId) CreateChildMenu(breadCrumb, category.CategoryId, currentCategory, level); } }
protected void CreateChildMenu(List <Category> breadCrumb, int rootCategoryId, Category currentCategory, int level) { int padding = level++ *15; foreach (var category in this.CategoryService.GetAllCategoriesByParentCategoryId(rootCategoryId)) { var link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryUrl(category); if (currentCategory != null && currentCategory.CategoryId == category.CategoryId) { link.CssClass = "active"; } else { link.CssClass = "inactive"; } link.HyperLink.NavigateUrl = categoryURL; string catName = string.Empty; if (this.SettingManager.GetSettingValueBoolean("Display.Products.ShowCategoryProductNumber")) { //display category name with assigned products number int numberOfProducts = GetNumberOfProducts(category, this.SettingManager.GetSettingValueBoolean("Display.Products.ShowCategoryProductNumber.IncludeSubCategories")); catName = string.Format("{0} ({1})", category.LocalizedName, numberOfProducts); } else { //display only category name catName = category.LocalizedName; } link.HyperLink.Text = Server.HtmlEncode(catName); if (padding > 0) { link.LiLeftMargin = padding.ToString(); } for (int i = 0; i <= breadCrumb.Count - 1; i++) { if (breadCrumb[i].CategoryId == category.CategoryId) { CreateChildMenu(breadCrumb, category.CategoryId, currentCategory, level); } } } }
protected void CreateChildMenu(CategoryCollection breadCrumb, int rootCategoryID, Category currentCategory, int level) { if (level < 2) { int id = 1; CategoryCollection categoryCollection = CategoryManager.GetAllCategories(rootCategoryID); if (level == 0) { rootCategories = categoryCollection; } foreach (Category category in categoryCollection) { NopCommerceLi link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryURL(category.CategoryID); link.Id = id; link.ParentId = parentId; link.Level = level; link.TotalMenuItems = categoryCollection.Count; link.Title = Server.HtmlEncode(category.Name); link.NavigateUrl = categoryURL; link.Picture = category.Picture; link.MaxCount = rootCategories.Count; CategoryCollection subCategories = CategoryManager.GetAllCategories(category.CategoryID, false); if (subCategories.Count > 0) { link.ChildCategoryUrl = SEOHelper.GetCategoryURL(subCategories[0].CategoryID); } CreateChildMenu(breadCrumb, category.CategoryID, currentCategory, level + 1); id++; if (level == 0) { parentId++; } } } }
protected void CreateChildMenu(List<Category> breadCrumb, int rootCategoryId, Category currentCategory, int level) { int padding = level++ * 15; foreach (var category in CategoryManager.GetAllCategoriesByParentCategoryId(rootCategoryId)) { var link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryUrl(category); if (currentCategory != null && currentCategory.CategoryId == category.CategoryId) link.CssClass = "active"; else link.CssClass = "inactive"; link.HyperLink.NavigateUrl = categoryURL; link.HyperLink.Text = Server.HtmlEncode(category.LocalizedName); if (padding > 0) link.LiLeftMargin = padding.ToString(); for (int i = 0; i <= breadCrumb.Count - 1; i++) if (breadCrumb[i].CategoryId == category.CategoryId) CreateChildMenu(breadCrumb, category.CategoryId, currentCategory, level); } }
protected void CreateChildMenu(CategoryCollection breadCrumb, int rootCategoryID, Category currentCategory, int level) { if (level < 2) { int id = 1; CategoryCollection categoryCollection = CategoryManager.GetAllCategories(rootCategoryID); if(level == 0) { rootCategories = categoryCollection; } foreach (Category category in categoryCollection) { NopCommerceLi link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryURL(category.CategoryID); link.Id = id; link.ParentId = parentId; link.Level = level; link.TotalMenuItems = categoryCollection.Count; link.Title = Server.HtmlEncode(category.Name); link.NavigateUrl = categoryURL; link.Picture = category.Picture; link.MaxCount = rootCategories.Count; CategoryCollection subCategories = CategoryManager.GetAllCategories(category.CategoryID, false); if(subCategories.Count > 0) { link.ChildCategoryUrl = SEOHelper.GetCategoryURL(subCategories[0].CategoryID); } CreateChildMenu(breadCrumb, category.CategoryID, currentCategory, level + 1); id++; if (level == 0) parentId++; } } }