Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SharePoint site developed by someone else who's since left and who I have no access to.

The Quick Launch menu has some libraries at the top level (i.e. they look like headers). They also have various other views, and links under those headers. This is handy as the headers (and everything under them) are automatically hidden when the user does not have access to that library (we do not have Publishing turned on btw).

I have no idea how they did this! The URL of the library on the header is set but greyed out so definitely looks like this is the library itself rather than a manual heading.

I have a new library that I want to add in the same way but I'm stumped. I can either add a manual header and put the library under the header (but then the header shows all the time), or I can turn on Publishing and set the audience of the manual header (but not sure of the impact of turning this on).

Any ideas?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Fixed this myself. I had to write a C# program to systematically add the Library to the Quick Launch menu at the top level. This is then compiled and run on the server as a user with the permissions to edit the SharePoint site.

Amazed that SharePoint accepts this (and why they don't give a nicer option in the GUI to do this since it apparently does handle it!).

Code below in case anyone else fancies it (knocked up very quickly so I'm sure it could be written better):


using System;
using System.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {

            if (args.Length < 2)
            {
                Console.WriteLine("Usage:\n");
                Console.WriteLine("\t" + Environment.GetCommandLineArgs()[0] + " URL LibraryToAdd\n");
                Console.WriteLine("where:\n");
                Console.WriteLine("\t URL is the name of the SharePoint site\n");
                Console.WriteLine("\t LibraryToAdd is Library you want added to the QuickLaunch menu\n");
                Environment.Exit(1);
            }

            string sharePointURL = args[0];
            string librarytoAdd = args[1];

            Console.WriteLine("Copying " + librarytoAdd + " from QuickLaunch->Libraries to top level on : " + sharePointURL + " SharePoint site\n");

            using (SPSite site = new SPSite(sharePointURL))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    // Get the Quick Launch headings.

                    SPNavigationNodeCollection ql = web.Navigation.QuickLaunch;

                    SPNavigationNode heading;
                    SPNavigationNode subheading;

                    // Get the Libraries Quick Launch area
                    heading = ql
                        .Cast()
                        .FirstOrDefault(n => n.Title == "Libraries");

                    if (heading != null)
                    {
                        // Get the one we want to move
                        subheading = heading.Children
                            .Cast()
                            .FirstOrDefault(n => n.Title == librarytoAdd);

                        if (subheading != null)
                        {
                            Console.Write("Adding to QuickLaunch\n");
                            ql.AddAsLast(subheading);
                        }
                        else
                        {
                            Console.Write("Can not find " + librarytoAdd + " in Quick Launch->Libraries\n");
                        }

                    }
                    else
                    {
                        Console.Write("Can not find Quick Launch->Libraries\n");
                    }

                }
            }
        }
    }
}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.