// // TODO: Add constructor logic here // public void PopulateStoreMenu2(EasyMenu ctrlMenu, EasyMenu[] ids) { //check if the product already exists in the cache System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuNavigation"]; if (ds == null) { CategoryHelper categoryHelper = new CategoryHelper(); ds = categoryHelper.GetNavigationItems(ZNodeConfigManager.SiteConfig.PortalID); //add the hierarchical relationship to the dataset ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]); HttpContext.Current.Cache["MenuNavigation"] = ds; } System.Data.DataSet dsBrands = (System.Data.DataSet)HttpContext.Current.Cache["SubMenuBrands"]; if (dsBrands == null) { GoOpticCategoryHelper gocategoryHelper = new GoOpticCategoryHelper(); dsBrands = gocategoryHelper.GetBrands(ZNodeConfigManager.SiteConfig.PortalID); //add the hierarchical relationship to the dataset //dsBrands.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]); HttpContext.Current.Cache["SubMenuBrands"] = dsBrands; } int CategoryNo = 0; foreach (DataRow dbRow in ds.Tables[0].Rows) { if (dbRow.IsNull("ParentCategoryID")) { if ((bool)dbRow["VisibleInd"]) { //create new menu item // string itemText = dbRow["Name"].ToString(); int rows; try { rows = Int32.Parse(dbRow["Rows"].ToString()); } catch (Exception e) { rows = 0; } int columns; try { columns = Int32.Parse(dbRow["Columns"].ToString()); } catch (Exception e) { columns = 0; } string categoryId = dbRow["CategoryId"].ToString(); string seoURL = dbRow["SEOURL"].ToString(); string imageName=dbRow["ImageFile"].ToString(); string imageNameHOver = imageName.Replace(".","HOver."); string imagePath = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath +imageName ; imagePath = imagePath.Replace("~",""); string imagePathHOver = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath+imageNameHOver; imagePathHOver = imagePathHOver.Replace("~", ""); string categoryText = dbRow["Name"].ToString(); if (categoryText.ToLower() == "home") seoURL = "~/"; else seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); imageName = imageName.Remove(imageName.IndexOf("."), imageName.Length - imageName.IndexOf(".")); string itemText = "<a href=\"" + seoURL.Replace("~","") + "\" onmouseover=\"roll_over('" + imageName + "', '" + imagePathHOver + "')\" onmouseout=\"roll_over('" + imageName + "', '" + imagePath + "')\" ><img border=\"0\" name =\"" + imageName + "\" src=\"" + imagePath + "\"/>"; // itemText = itemText.Replace("default", imagePath); categoryText = categoryText.Replace(" ", ""); string sepID = "sep" + categoryText; string sepPath = "<img src=\"~/Images/home/bete.png\"/>"; sepPath = sepPath.Replace("~", ""); if(CategoryNo!=0) ctrlMenu.AddSeparator(sepID, sepPath); OboutInc.EasyMenu_Pro.MenuItem mi = new OboutInc.EasyMenu_Pro.MenuItem(categoryText, itemText, "","", "", ""); ctrlMenu.AddItem(mi); ids[CategoryNo].AttachTo = categoryText; //recursively populate node if (categoryText.ToLower() == "brands") { RecursivelyPopulateMenuBrands(ids[CategoryNo], rows, columns); } else { RecursivelyPopulateMenuSubCategory(dbRow, ids[CategoryNo], dsBrands, rows, columns); // RecursivelyPopulateMenuBrands(ids[CategoryNo], categoryId, dsBrands); } CategoryNo++; } } } }
private void RecursivelyPopulateMenuBrands(EasyMenu parentMenuItem, int rows, int columns) { //check if the product already exists in the cache System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuBrands"]; if (ds == null) { GoOpticCategoryHelper categoryHelper = new GoOpticCategoryHelper(); ds = categoryHelper.GetBrandNavigationItems(ZNodeConfigManager.SiteConfig.PortalID); HttpContext.Current.Cache["MenuBrands"] = ds; } parentMenuItem.Align = MenuAlign.Under; parentMenuItem.Position = MenuPosition.Horizontal; parentMenuItem.ShowEvent = MenuShowEvent.MouseOver; if (columns >= 2) parentMenuItem.RepeatColumns = 2*columns-1; parentMenuItem.Width = (100 * columns).ToString(); parentMenuItem.UseIcons = true; parentMenuItem.ZIndex = 400; parentMenuItem.ExpandStyle = ExpandStyle.Slide; string iconPath = "~/Images/home/"; iconPath = iconPath.Replace("~", ""); parentMenuItem.IconsFolder = iconPath; int alphabetLetters = 0; string alphabet =String.Empty; foreach (DataRow dbRow in ds.Tables[0].Rows) { string brandName = dbRow["Name"].ToString(); string firstLetter = brandName.Substring(0, 1); if (alphabet != firstLetter) { alphabet = firstLetter; alphabetLetters++; } } int BrandsPerCol=(int)Math.Ceiling((double)(ds.Tables[0].Rows.Count+alphabetLetters)/columns); int brandNo = 0; int currentCol = 0; alphabet = String.Empty; OboutInc.EasyMenu_Pro.MenuItem miBrand; foreach (DataRow dbRow in ds.Tables[0].Rows) { string brandName = dbRow["Name"].ToString(); string firstLetter= brandName.Substring(0, 1); string itemBrandName = brandName.Replace(" ",""); if (alphabet != firstLetter) { alphabet = firstLetter; miBrand = new OboutInc.EasyMenu_Pro.MenuItem(alphabet, "<span id=\"alphabet\">" + alphabet.ToUpper() + "</span>", "", "", "", ""); miBrand.Disabled = true; if (currentCol == 0) { parentMenuItem.AddItemAt(brandNo,miBrand); }else{ parentMenuItem.AddItemAt((brandNo+1) *(currentCol+1)-1, miBrand); } brandNo++; if (brandNo+1 == BrandsPerCol) { currentCol++; brandNo = 0; } } string seoURL = " ";// = childRow["SEOURL"].ToString(); // seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); miBrand = new OboutInc.EasyMenu_Pro.MenuItem(itemBrandName, "<span >" + brandName + "</span>", "",seoURL, "", "");//id=\"menu_item\" if (currentCol == 0) { parentMenuItem.AddItemAt(brandNo, miBrand); } else { parentMenuItem.AddItemAt((brandNo + 1) * (currentCol + 1) - 1, miBrand); } brandNo++; if (brandNo+1 == BrandsPerCol) { currentCol++; brandNo = 0; } } int sepCount=1; int colSepCount = 1; string sepPath = "<img src=\"~/Images/home/split_brand.jpg\"/>"; sepPath = sepPath.Replace("~", ""); for (int i = 0; i < (columns-1) * BrandsPerCol;i++ ) { parentMenuItem.AddSeparatorAt(sepCount, "sep" + sepCount.ToString(), sepPath); sepCount+=2*columns-1; if ((i + 1)%BrandsPerCol==0) { colSepCount += 2; sepCount = colSepCount; } } }