Example #1
0
        public override void AddNavigationNode(string title, string url, NavigationNodeLocation location)
        {
            NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();

            newNavNode.Title = title;
            newNavNode.Url   = url;

            NavigationNodeCollection navNodeColl = null;

            switch (location)
            {
            case NavigationNodeLocation.TopNavigationBar:
                navNodeColl = _web.Navigation.TopNavigationBar;
                break;

            case NavigationNodeLocation.QuickLaunchLists:
                navNodeColl = _web.Navigation.QuickLaunch;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(location), location, null);
            }


            try
            {
                navNodeColl.Add(newNavNode);
                _context.ExecuteQuery();
            }
            catch (Exception)
            {
                //ignore, already exists
            }
        }
Example #2
0
        public override void AddNavigationNode(string title, string url, NavigationNodeLocation location)
        {
            SPNavigationNodeCollection topnav = null;
            SPNavigationNode           node   = new SPNavigationNode(title, url);

            if (_spWeb.Navigation.GetNodeByUrl(node.Url) != null)
            {
                return;
            }
            switch (location)
            {
            case NavigationNodeLocation.TopNavigationBar:
                topnav = _spWeb.Navigation.TopNavigationBar;
                topnav.AddAsLast(node);
                break;

            case NavigationNodeLocation.QuickLaunchLists:
                _spWeb.Navigation.AddToQuickLaunch(node, SPQuickLaunchHeading.Lists);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(location), location, null);
            }
        }
Example #3
0
        public override void AddNavigationNode(string title, string url, NavigationNodeLocation location)
        {
            NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
            newNavNode.Title = title;
            newNavNode.Url = url;

            NavigationNodeCollection navNodeColl = null;
            switch (location)
            {
                case NavigationNodeLocation.TopNavigationBar:
                    navNodeColl = _web.Navigation.TopNavigationBar;
                    break;
                case NavigationNodeLocation.QuickLaunchLists:
                    navNodeColl = _web.Navigation.QuickLaunch;
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(location), location, null);
            }

            try
            {
                navNodeColl.Add(newNavNode);
                _context.ExecuteQuery();
            }
            catch (Exception)
            {
                //ignore, vec postoji
            }
        }
Example #4
0
 public abstract void AddNavigationNode(string title, string url, NavigationNodeLocation location);
Example #5
0
 public abstract void AddNavigationNode(string title, string url, NavigationNodeLocation location);
Example #6
0
 public override void AddNavigationNode(string title, string url, NavigationNodeLocation location)
 {
     SPNavigationNodeCollection topnav = null;
     SPNavigationNode node = new SPNavigationNode(title, url);
     if (_spWeb.Navigation.GetNodeByUrl(node.Url) != null)
     {
         return;
     }
     switch (location)
     {
         case NavigationNodeLocation.TopNavigationBar:
             topnav = _spWeb.Navigation.TopNavigationBar;
             topnav.AddAsLast(node);
             break;
         case NavigationNodeLocation.QuickLaunchLists:
             _spWeb.Navigation.AddToQuickLaunch(node, SPQuickLaunchHeading.Lists);
             break;
         default:
             throw new ArgumentOutOfRangeException(nameof(location), location, null);
     }
 }