Example #1
0
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            PortalSiteMapNode pNode = node as PortalSiteMapNode;

            if (pNode != null)
            {
                if (pNode.Type == NodeTypes.Area && pNode.WebId == SPContext.Current.Site.RootWeb.ID)
                {
                    SiteMapNodeCollection nodeColl  = base.GetChildNodes(pNode);
                    SiteMapNode           childNode = new SiteMapNode(this,
                                                                      "<http://www.google.com>", "http://www.google.com",
                                                                      "Google");

                    SiteMapNode childNode1 = new SiteMapNode(this,
                                                             "<http://www.bing.com>",
                                                             "http://www.bing.com", "Bing");
                    SiteMapNode childNode2 = new SiteMapNode(this,
                                                             "<http://www.hardocp.com>",
                                                             "http://www.hardocp.com", "hardocp");

                    nodeColl.Add(childNode);

                    SiteMapNodeCollection test = new SiteMapNodeCollection();
                    test.Add(childNode1);
                    test.Add(childNode2);
                    childNode.ChildNodes = test;



                    return(nodeColl);
                }
                return(base.GetChildNodes(pNode));
            }
            return(new SiteMapNodeCollection());
        }
 // renders the text of the Node as a link or plain text
 private void RenderNodeItem(PlaceHolder placeHolder, SiteMapNode node, string cssClass)
 {
     // only render if it is not the root
     if (node.Url.ToLower().IndexOf("/eng/pages") == -1 && node.Url.ToLower().IndexOf("/fra/pages") == -1 && node.ParentNode != null)
     {
         if (String.IsNullOrEmpty(node.Url))
         {
             placeHolder.Controls.Add(new LiteralControl(node.Title));
         }
         else
         {
             HyperLink hyperlink = new HyperLink();
             hyperlink.NavigateUrl = node.Url;
             hyperlink.CssClass    = cssClass;
             if (node is PortalSiteMapNode)
             {
                 PortalSiteMapNode portalNode = node as PortalSiteMapNode;
                 if (portalNode.Target != null)
                 {
                     hyperlink.Target = portalNode.Target;
                 }
             }
             hyperlink.Text = node.Title;
             placeHolder.Controls.Add(hyperlink);
         }
     }
 }
Example #3
0
        public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode
                                                            node)
        {
            PortalSiteMapNode pNode = node as PortalSiteMapNode;

            if (pNode != null)
            {
                if (pNode.Type == NodeTypes.Area)
                {
                    SiteMapNodeCollection nodeColl  = base.GetChildNodes(pNode);
                    SiteMapNode           childNode = new SiteMapNode(this,
                                                                      "<http://www.microsoft.com>", "<http://www.microsoft.com>", "Microsoft");

                    SiteMapNode childNode1 = new SiteMapNode(this,
                                                             "<http://support.microsoft.com>", "<http://support.microsoft.com>", "Support");

                    nodeColl.Add(childNode);

                    SiteMapNodeCollection test = new SiteMapNodeCollection();
                    test.Add(childNode1);
                    childNode.ChildNodes = test;

                    return(nodeColl);
                }
                else
                {
                    return(base.GetChildNodes(pNode));
                }
            }
            else
            {
                return(new SiteMapNodeCollection());
            }
        }
        //Get the existing collection of site nodes
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            //Store the node passed to the method and the current node and PortalSiteMapNodes
            PortalSiteMapNode pNode       = node as PortalSiteMapNode;
            PortalSiteMapNode currentNode = CurrentNode as PortalSiteMapNode;

            if ((pNode != null) && (currentNode != null))
            {
                //Check that we the node passed in is a SharePoint Site (SPWeb)
                if (pNode.Type == NodeTypes.Area)
                {
                    //Get the site's node collection
                    SiteMapNodeCollection nodeCollection = base.GetChildNodes(pNode);
                    //Create two new nodes
                    PortalSiteMapNode newChildNode1 = new PortalSiteMapNode(currentNode.WebNode, "customnodemsdn", NodeTypes.Custom, "http://msdn.microsoft.com", "MSDN", "Microsoft Solution Developer Network");
                    PortalSiteMapNode newChildNode2 = new PortalSiteMapNode(currentNode.WebNode, "customnodetechnet", NodeTypes.Custom, "http://technet.microsoft.com", "TechNet", "Microsoft IT Pro documentation");
                    //Add them
                    nodeCollection.Add(newChildNode1);
                    nodeCollection.Add(newChildNode2);
                    //Return the collection
                    return(nodeCollection);
                }
                else
                {
                    //The node passed into this method is not a SharePoint site so we take no action
                    return(base.GetChildNodes(pNode));
                }
            }
            else
            {
                //Couldn't find either the node passed in or the current node. Return an empty collection
                return(new SiteMapNodeCollection());
            }
        }
Example #5
0
        public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
        {
            PortalSiteMapNode pNode = node as PortalSiteMapNode;

            if (pNode != null)
            {
                if (pNode.Type == NodeTypes.Area)
                {
                    SiteMapNodeCollection nodeColl = new SiteMapNodeCollection();

                    //get and add each node
                    List <MenuItem> menuItems = GetMenuItemsForCurrentUser();
                    //get the top level nodes
                    var topNodes = from m in menuItems where String.IsNullOrEmpty(m.ParentItem) orderby m.SortOrder ascending select m;
                    //add topNodes
                    foreach (MenuItem menu in topNodes)
                    {
                        SiteMapNode cNode = new SiteMapNode(this, menu.Name, menu.URL, menu.Name);
                        cNode.ChildNodes = GetSubNodes(menuItems, menu);
                        nodeColl.Add(cNode);
                    }
                    return(nodeColl);
                }
                else
                {
                    return(base.GetChildNodes(pNode));
                }
            }
            else
            {
                return(new SiteMapNodeCollection());
            }
        }
Example #6
0
 private SiteMapNode SetNavNode(PortalSiteMapNode portalNode, Term termNode)
 {
     try
     {
         var friendlyURL = termNode.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"];
         var navNode     = new PortalSiteMapNode(portalNode.WebNode,
                                                 termNode.Id.ToString(),
                                                 NodeTypes.Heading,
                                                 friendlyURL,
                                                 termNode.Name,
                                                 string.Empty);
         return(navNode);
     }
     catch (KeyNotFoundException ex)
     {
         var friendlyURL = string.Empty;
         var navNode     = new PortalSiteMapNode(portalNode.WebNode,
                                                 termNode.Id.ToString(),
                                                 NodeTypes.Heading,
                                                 friendlyURL,
                                                 termNode.Name,
                                                 string.Empty);
         return(navNode);
     }
 }
Example #7
0
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            SiteMapNodeCollection siteMapNodes = new SiteMapNodeCollection();
            // cast from .net node to portalnode
            PortalSiteMapNode portalNode = node as PortalSiteMapNode;

            // check it
            if (portalNode == null)
            {
                return(siteMapNodes);
            }
            TaxonomySession taxonomySession = new TaxonomySession(SPContext.Current.Site);
            TermStore       termStore       = taxonomySession.TermStores[0];
            Group           termGroup       = termStore.Groups["BeckyTermGroup"];
            TermSet         termSet         = termGroup.TermSets["BeckyTermSet"];

            // root
            if (node.Key.ToLower() == SPContext.Current.Web.ServerRelativeUrl.ToLower())
            {
                foreach (var term in termSet.Terms)
                {
                    siteMapNodes.Add(SetNavNode(portalNode, term));
                }
            }
            else
            {
                var subTerm = termSet.GetTerm(new Guid(node.Key));
                foreach (var term in subTerm.Terms)
                {
                    siteMapNodes.Add(SetNavNode(portalNode, term));
                }
            }

            return(siteMapNodes);
        }
Example #8
0
 public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode 
 node)
 {
 PortalSiteMapNode pNode = node as PortalSiteMapNode;
 if (pNode != null)
 {
 if (pNode.Type == NodeTypes.Area)
 {
Example #9
0
 private int CurrentNodeLevel(PortalSiteMapNode node, ref int level)
 {
     PortalSiteMapNode parentNode = node.ParentNode as PortalSiteMapNode;
     if (parentNode != null)
     {
         level++;
         CurrentNodeLevel(parentNode, ref level);
     }
     return level;
 }
Example #10
0
 private int GetOffset(PortalSiteMapNode node)
 {
     int offSet = 0;
     int level = 0;
     //get level
     CurrentNodeLevel(node, ref level);
     if (level > 0)
     {
         offSet = -1 * (level + 1);
     }
     return offSet;
 }
Example #11
0
 private bool CheckHeirarychy(SiteMapNode currentNode, PortalSiteMapNode node)
 {
     bool flag = false;
     SiteMapNode tempNode = currentNode;
     while (tempNode != null)
     {
         if (tempNode == node ||
             tempNode == node.ParentNode)
         {
             flag = true;
             break;
         }
         tempNode = tempNode.ParentNode;
     }
     return flag;
 }