コード例 #1
0
    private void GenerateParent(string parentCategoryID, Panel panel)
    {
        foreach (Category category in _catalog)
        {
            if (category.CategoryID == parentCategoryID)
            {
                string name                = category.Name;
                string categoryID          = category.CategoryID;
                string urlName             = category.UrlName;
                string newparentCategoryID = category.ParentCategoryID;

                GenerateParent(newparentCategoryID, panel);
                HyperLink link = new HyperLink();
                link.NavigateUrl = UrlManager.GetCategoryUrl(categoryID, urlName);
                link.Text        = name;
                link.CssClass    = "SiteMapParent";
                panel.Controls.Add(link);

                Label label = new Label();
                label.Text     = " >> ";
                label.CssClass = "SiteMapSeparate";
                panel.Controls.Add(label);
            }
        }
    }
コード例 #2
0
    private TreeNode NewNode(Category category)
    {
        TreeNode newNode = new TreeNode();

        newNode.Text  = category.Name;
        newNode.Value = category.CategoryID.ToString();

        if (DataAccessContext.CategoryRepository.IsCategoryIDNotLeaf(category.CategoryID))
        {
            newNode.SelectAction = TreeNodeSelectAction.Expand;
            newNode.NavigateUrl  = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
            newNode.Collapse();
            nodeDepth++;
            if (nodeDepth < MaxNode) //Max Tree depth
            {
                PopulateCategories(newNode, category.CategoryID);
            }
            nodeDepth--;
        }
        else
        {
            newNode.SelectAction     = TreeNodeSelectAction.Select;
            newNode.NavigateUrl      = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
            newNode.PopulateOnDemand = true;
        }
        return(newNode);
    }
コード例 #3
0
    protected string CreateItemWithChildren(Category category)
    {
        StringBuilder sb          = new StringBuilder();
        string        categoryUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName).Split('/')[1];

        if (DataAccessContext.CategoryRepository.IsCategoryIDNotLeaf(category.CategoryID))
        {
            IList <Category> list = DataAccessContext.CategoryRepository.GetByParentID(
                StoreContext.Culture,
                category.CategoryID,
                "SortOrder",
                BoolFilter.ShowTrue);

            sb.Append("<li class=\"has-dropdown\">");
            sb.Append("    <a href=\"" + categoryUrl + "\">" + category.Name + "</a>");
            sb.Append("    <ul class=\"dropdown\">");

            foreach (Category subCategory in list)
            {
                sb.Append(CreateItemWithChildren(subCategory));
            }
            sb.Append("    </ul>");
            sb.Append("</li>");
        }
        else
        {
            sb.Append("<li>");
            sb.Append("    <a href=\"" + categoryUrl + "\">" + category.Name + "</a>");
            sb.Append("</li>");
        }

        return(sb.ToString());
    }
コード例 #4
0
    private void PopulateMenu()
    {
        HtmlGenericControl ul = new HtmlGenericControl("ul");

        ul.Attributes.Add("class", "left");

        string           rootID       = DataAccessContext.Configurations.GetValue("RootCategory", new StoreRetriever().GetStore());
        IList <Category> categoryList = DataAccessContext.CategoryRepository.GetByParentIDAndRootID(
            StoreContext.Culture, rootID, rootID, "SortOrder", BoolFilter.ShowTrue);

        foreach (Category category in categoryList)
        {
            HtmlGenericControl li = new HtmlGenericControl("li");

            if (DataAccessContext.CategoryRepository.IsCategoryIDNotLeaf(category.CategoryID))
            {
                li.Attributes.Add("class", "has-dropdown");

                StringBuilder sb = new StringBuilder();

                string categoryUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName).Split('/')[1];

                sb.Append("<a href=\"" + categoryUrl + "\">" + category.Name + "</a>");
                sb.Append("    <ul class=\"dropdown\">");

                IList <Category> list = DataAccessContext.CategoryRepository.GetByParentID(
                    StoreContext.Culture,
                    category.CategoryID,
                    "SortOrder",
                    BoolFilter.ShowTrue);
                foreach (Category subcategory in list)
                {
                    sb.Append(CreateItemWithChildren(subcategory));
                }

                sb.Append("    </ul>");

                li.InnerHtml = sb.ToString();
            }
            else
            {
                HyperLink hl = new HyperLink();

                hl.CssClass    = "HyperLink";
                hl.NavigateUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
                hl.Text        = category.Name;

                li.Controls.Add(hl);
            }

            ul.Controls.Add(li);
        }
        uxMenuPanel.Controls.Add(ul);
    }
コード例 #5
0
        private SiteMapNode CreateSiteMapNodeCategory(Category category)
        {
            string url = String.Empty;

            if (UrlManager.IsFacebook())
            {
                url = UrlManager.GetFacebookCategoryUrl(category.CategoryID, category.UrlName);
            }
            else
            {
                url = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
            }

            SiteMapNode node = new SiteMapNode(this,
                                               CreateUniqueCategoryID(category.CategoryID), url, category.Name, category.Description, null, null, null, null);

            return(node);
        }
コード例 #6
0
    private void GenerateBreadcrumb(DataListItem item)
    {
        Panel  panel            = (Panel)item.FindControl("uxBreadcrumbPanel");
        string name             = DataBinder.Eval(item.DataItem, "Name").ToString();
        string categoryID       = DataBinder.Eval(item.DataItem, "CategoryID").ToString();
        string urlName          = DataBinder.Eval(item.DataItem, "UrlName").ToString();
        string parentCategoryID = DataBinder.Eval(item.DataItem, "ParentCategoryID").ToString();

        GenerateParent(parentCategoryID, panel);
        HyperLink link = new HyperLink();

        link.NavigateUrl = UrlManager.GetCategoryUrl(categoryID, urlName);
        link.Text        = name;
        link.CssClass    = "SiteMapBreadcrumb";

        panel.Controls.Add(link);

        GenerateProduct(item, categoryID);
    }
コード例 #7
0
    private void Catalog_StoreCultureChanged(object sender, CultureEventArgs e)
    {
        if (CurrentCategoryName == "")
        {
            Response.Redirect("~/Catalog.aspx");
        }
        else
        {
            Category category = DataAccessContext.CategoryRepository.GetOne(
                StoreContext.Culture, CatalogID);

            if (!String.IsNullOrEmpty(category.UrlName))
            {
                Response.Redirect(UrlManager.GetCategoryUrl(CatalogID, category.UrlName));
            }
            else
            {
                Response.Redirect("~/Error404.aspx");
            }
        }
    }
コード例 #8
0
    protected MenuItem CreateMenuItemWithChildren(Category category)
    {
        MenuItem newItem = new MenuItem();

        if (DataAccessContext.CategoryRepository.IsCategoryIDNotLeaf(category.CategoryID))
        {
            newItem.Text        = category.Name;
            newItem.Value       = category.CategoryID;
            newItem.NavigateUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);

            PopulateCategories(newItem, category.CategoryID);
        }
        else
        {
            newItem.Text        = category.Name;
            newItem.Value       = category.CategoryID;
            newItem.NavigateUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
        }

        return(newItem);
    }
コード例 #9
0
    protected string GetURL(object dataItem)
    {
        Category category = (Category)dataItem;

        return(UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName));
    }
コード例 #10
0
    private void PopulateMenu()
    {
        HtmlGenericControl ul = new HtmlGenericControl("ul");

        string           rootID       = DataAccessContext.Configurations.GetValue("RootCategory", new StoreRetriever().GetStore());
        IList <Category> categoryList = DataAccessContext.CategoryRepository.GetByParentIDAndRootID(
            StoreContext.Culture, rootID, rootID, "SortOrder", BoolFilter.ShowTrue);


        foreach (Category category in categoryList)
        {
            HtmlGenericControl li   = new HtmlGenericControl("li");
            HtmlGenericControl div1 = new HtmlGenericControl("div");
            HtmlGenericControl div2 = new HtmlGenericControl("div");

            div1.Attributes.Add("class", "HeaderMenuNavItemLeft");
            div2.Attributes.Add("class", "HeaderMenuNavItemRight");

            if (DataAccessContext.CategoryRepository.IsCategoryIDNotLeaf(category.CategoryID))
            {
                Menu CategoryDropDownMenu = new Menu();
                int  MaxNode = DataAccessContext.Configurations.GetIntValue("CategoryDynamicDropDownLevel");
                CategoryDropDownMenu.CssClass = "ContentMenuNavMenuList";
                CategoryDropDownMenu.StaticHoverStyle.CssClass      = "ContentMenuNavMenuListStaticHover";
                CategoryDropDownMenu.StaticMenuItemStyle.CssClass   = "ContentMenuNavListStaticMenuItem";
                CategoryDropDownMenu.StaticSelectedStyle.CssClass   = "ContentMenuNavMenuListStaticSelectItem";
                CategoryDropDownMenu.StaticMenuStyle.CssClass       = "ContentMenuNavMenuListStaticMenuStyle";
                CategoryDropDownMenu.DynamicHoverStyle.CssClass     = "ContentMenuNavMenuListDynamicHover";
                CategoryDropDownMenu.DynamicMenuItemStyle.CssClass  = "ContentMenuNavMenuListDynamicMenuItem";
                CategoryDropDownMenu.DynamicSelectedStyle.CssClass  = "ContentMenuNavMenuListDynamicSelectItem";
                CategoryDropDownMenu.DynamicMenuStyle.CssClass      = "ContentMenuNavMenuListDynamicMenuStyle";
                CategoryDropDownMenu.StaticEnableDefaultPopOutImage = false;
                CategoryDropDownMenu.Orientation = Orientation.Horizontal;
                CategoryDropDownMenu.MaximumDynamicDisplayLevels = MaxNode;

                MenuItem rootMenu = new MenuItem();
                rootMenu.Text        = category.Name;
                rootMenu.NavigateUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);

                IList <Category> list = DataAccessContext.CategoryRepository.GetByParentID(
                    StoreContext.Culture,
                    category.CategoryID,
                    "SortOrder",
                    BoolFilter.ShowTrue);
                foreach (Category subcategory in list)
                {
                    rootMenu.ChildItems.Add(CreateMenuItemWithChildren(subcategory));
                }

                CategoryDropDownMenu.Items.Add(rootMenu);

                div2.Controls.Add(CategoryDropDownMenu);
            }
            else
            {
                HyperLink hl = new HyperLink();

                hl.CssClass    = "HyperLink";
                hl.NavigateUrl = UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName);
                hl.Text        = category.Name;

                div2.Controls.Add(hl);
            }

            div1.Controls.Add(div2);
            li.Controls.Add(div1);
            ul.Controls.Add(li);
        }
        uxHeaderMenu3PlaceHolder.Controls.Add(ul);
    }
コード例 #11
0
    protected string GetMoreURL()
    {
        Category category = DataAccessContext.CategoryRepository.GetOne(StoreContext.Culture, CategoryID);

        return(UrlManager.GetCategoryUrl(category.CategoryID, category.UrlName));
    }