Exemple #1
0
        private SiteMapNode SiteMap_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
        {
            if (SiteMap.CurrentNode == null)
            {
                String url = e.Context.Request.RawUrl;

                if (url.Contains("TheLoai/"))
                {
                    CategoryModel categoryLogic   = new CategoryModel();
                    String        parentNodeTitle = "Thể Loại";
                    String        subNodeAlias    = url.Substring(url.IndexOf("TheLoai") + 8);
                    String        subNodeTitle    = categoryLogic.GetCategoryNameByAlias(subNodeAlias).Name;

                    SiteMapNode parentNode = new SiteMapNode(e.Provider, url.Substring(0, 8), null, parentNodeTitle);
                    SiteMapNode childNode  = new SiteMapNode(e.Provider, url, null, subNodeTitle);
                    parentNode.ParentNode = SiteMap.RootNode;
                    childNode.ParentNode  = parentNode;

                    return(childNode);
                }
                else if (url.Contains("TaiLieu/"))
                {
                    DocumentModel docLogic        = new DocumentModel();
                    String        parentNodeTitle = "Tài Liệu";
                    String[]      DocFullName     = url.Substring(url.IndexOf("TaiLieu") + 8).Split('-');
                    String        subNodeAlias    = DocFullName[1];
                    String        subNodeTitle    = docLogic.GetDocumentById(Int32.Parse(DocFullName[0])).Name;

                    SiteMapNode parentNode = new SiteMapNode(e.Provider, url.Substring(0, 8), null, parentNodeTitle);
                    SiteMapNode childNode  = new SiteMapNode(e.Provider, url, null, subNodeTitle);
                    parentNode.ParentNode = SiteMap.RootNode;
                    childNode.ParentNode  = parentNode;

                    return(childNode);
                }

                bool IsHomePage = url.Contains("default.aspx") || url == "/";

                if (IsHomePage)
                {
                    SiteMapNode node = new SiteMapNode(e.Provider, url, url, "Trang Chủ");
                    return(node);
                }
            }
            return(SiteMap.CurrentNode);
        }