Exemple #1
0
        private void CreateBreadcrumb()
        {
            if (!CurrentCategory.IsNull)
            {
                Breadcrumb = CategoryBreadcrumbNode.BuildBreadCrumbs(CurrentCategory);
            }

            Bind();
        }
Exemple #2
0
        private void SetupCategories()
        {
            Category        currentCategory = Category.Empty;
            List <Category> categoryList    = new List <Category>();

            if (CategoryId > 0)
            {
                // Display all subcategories od the selected category

                currentCategory = CategoryCache.Instance.GetById(CategoryId);
                categoryList    = currentCategory.SubCategories;
            }
            else if (BrandDropDownList1.SelectedId == 0)
            {
                // Display all categories across all brands to which the user has access

                currentCategory = Category.Empty;

                if (CurrentUser.Brands.Count == 1)
                {
                    currentCategory = CategoryCache.Instance.GetRootCategory(CurrentUser.Brands[0].BrandId.GetValueOrDefault());
                    categoryList    = currentCategory.SubCategories;
                }
                else
                {
                    foreach (Brand brand in CurrentUser.Brands)
                    {
                        int brandId = brand.BrandId.GetValueOrDefault();

                        Category parentCategory = CategoryCache.Instance.GetRootCategory(brandId);
                        categoryList.AddRange(parentCategory.SubCategories);
                    }
                }
            }
            else if (BrandDropDownList1.SelectedId > 0)
            {
                // Display all categories in the selected brand

                currentCategory = CategoryCache.Instance.GetRootCategory(BrandDropDownList1.SelectedId);
                categoryList    = currentCategory.SubCategories;
            }

            if (currentCategory.IsNull)
            {
                CategoryHeaderPlaceHolder.Visible = false;
                CategoryNameLabel.Text            = "All Categories";
            }
            else
            {
                CategoryHeaderPlaceHolder.Visible = true;

                // Populate breadcrumbs
                BreadcrumbRepeater.DataSource = CategoryBreadcrumbNode.BuildBreadCrumbs(currentCategory);
                BreadcrumbRepeater.DataBind();

                // Display the category navigation message
                string mailtoHtml = string.Format("<a href=\"mailto:{0}\">{1}</a>", currentCategory.OwnerEmail, currentCategory.OwnerName);
                CategoryNavigationMessage.Text       = currentCategory.Message.Replace("[category contact]", mailtoHtml);
                CategoryNavigationMessageDiv.Visible = (!StringUtils.IsBlank(CategoryNavigationMessage.Text));

                // Populate category name label
                string message = (categoryList.Count > 0) ? "Sub-Categories of " + currentCategory.Name : string.Empty;
                CategoryNameLabel.Text = message;

                // Append a BR onto the start of the category name if there's no category navigation, but there are breadcrumbs
                // and we have a category name. This is a very bad way of maintaining the layout, and an in interim fix
                // until the HTML is updated to use proper sematics with CSS properly controlling the layout.
                if (!CategoryNavigationMessageDiv.Visible && BreadcrumbRepeater.Items.Count > 0 && CategoryNameLabel.Text.Length > 0)
                {
                    CategoryNameLabel.Text = "<br />" + CategoryNameLabel.Text;
                }
            }

            // No point showing the category name wrapper if we don't have a category name
            if (StringUtils.IsBlank(CategoryNameLabel.Text))
            {
                CategoryNameDiv.Visible = false;
            }

            BindSubCategories(categoryList);
        }