private void WriteCategories(StringBuilder sb, List <Category> categoryCollection) { foreach (Category category in categoryCollection) { sb.Append("<li>"); sb.AppendFormat("<a href=\"{0}\">{1}</a>", SEOHelper.GetCategoryURL(category.CategoryID), Server.HtmlEncode(category.Name)); var childCategoryCollection = CategoryManager.GetAllCategories(category.CategoryID); if (childCategoryCollection.Count > 0) { sb.Append("<ul>"); WriteCategories(sb, childCategoryCollection); sb.Append("</ul>"); } else { int totalCount; var productCollection = ProductManager.GetAllProducts(category.CategoryID, 0, false, int.MaxValue - 1, 0, out totalCount); if (productCollection.Count > 0) { sb.Append("<ul>"); WriteProducts(sb, productCollection.ToList()); sb.Append("</ul>"); } } sb.Append("</li>"); } }
protected void dlSubCategories_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Category category = e.Item.DataItem as Category; string categoryURL = SEOHelper.GetCategoryURL(category.CategoryID); HyperLink hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink; if (hlImageLink != null) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(category.PictureID, SettingManager.GetSettingValueInteger("Media.Category.ThumbnailImageSize", 125), true); hlImageLink.NavigateUrl = categoryURL; hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Category.ImageAlternateTextFormat"), category.Name); } HyperLink hlCategory = e.Item.FindControl("hlCategory") as HyperLink; if (hlCategory != null) { hlCategory.NavigateUrl = categoryURL; hlCategory.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.Name); hlCategory.Text = Server.HtmlEncode(category.Name); } } }
private void ChangeCategoryMap(SiteMapResolveEventArgs e, SiteMapNode currentNode) { try { SiteMapNode tempNode = currentNode; Category category = CategoryManager.GetCategoryByID(CategoryId); if (0 != CategoryId) { tempNode.Url = SEOHelper.GetCategoryURL(category.CategoryID); CategoryCollection categCollection = CategoryManager.GetBreadCrumb(category.CategoryID); string categoryPath = categCollection.Aggregate(String.Empty, (current, c) => current + String.Format( String.IsNullOrEmpty(current) ? "{0}" : "/{0}", c.Name)); tempNode.Title = categoryPath; tempNode.Description = categoryPath; } } catch { } }
protected void rptrSubCategories_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Category category = e.Item.DataItem as Category; HyperLink hlCategory = e.Item.FindControl("hlCategory") as HyperLink; if (hlCategory != null) { hlCategory.NavigateUrl = SEOHelper.GetCategoryURL(category.CategoryID); } } }
private void WriteCategories(int ParentCategoryID) { CategoryCollection categories = CategoryManager.GetAllCategories(ParentCategoryID, false); foreach (Category category in categories) { string url = SEOHelper.GetCategoryURL(category.CategoryID); UpdateFrequency updateFrequency = UpdateFrequency.weekly; DateTime updateTime = category.UpdatedOn; WriteUrlLocation(url, updateFrequency, updateTime); WriteCategories(category.CategoryID); } }
protected void rptrSubCategories_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Category category = e.Item.DataItem as Category; HyperLink hlCategory = e.Item.FindControl("hlCategory") as HyperLink; if (hlCategory != null) { hlCategory.NavigateUrl = SEOHelper.GetCategoryURL(category.CategoryID); hlCategory.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.Name); hlCategory.Text = Server.HtmlEncode(category.Name); } } }
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++; } } } }