I want to hide Category Links in the QuickLaunch: Libraries and Lists. They are defined in the onet.xml (navbars) which I copied from STS template.

enter image description here

I could hide them with css:

ul.root.static > li.static > a.static.menu-item {
    display: none;

Is there a better way to do it?

EDIT: I want to remove headers, not the children nodes.

| improve this question | | | | |
  • 1
    IMO this is the best way to do it. – Vedran Rasol Sep 24 '11 at 22:49

I'd do this with CSS or script. In my experience, this is the type of critical requirement that is usually reversed, as users find the groupings useful once they aren't there any more.

In other words, do it the "cheapest" way, then maybe instantiate it more "expensively" later if need be. The CSS or script route is totally acceptable technically, as long as it fits your governance model.

| improve this answer | | | | |
  • I'm not sure I understand the cheapest/expensive reference. The "cheapest" way would be to do it via the UI, which could also be undone. The code I provided is easy and would be no more "expensive" to implement than the CSS. It could also be wired to be add/removed on activation/deactivation allowing them to change their mind. I think the CSS and script could be more expensive if used on multiple sites. – Mike Oryszak Sep 25 '11 at 14:31
  • I agree with you, @Marc. Sometimes the cheapest way is the best way, especially if users would like to get the headers back - you just have to remove one css-rule. – Anatoly Mironov Sep 25 '11 at 16:13
  • @MikeOryszak, your code sample will delete the nodes and, of course the children nodes. I want to keep the children. One could simply delete navbars section in the onet so we don't need to write more code. – Anatoly Mironov Sep 25 '11 at 16:14
  • @AnatolyMironov You can change the code to re-categorize the children links with another header. Also, do NOT make manual modifications to the onet or other configuration files. This is not the right way to customize SharePoint and will cause problems. – Mike Oryszak Sep 25 '11 at 16:24
  • Mike: I meant cheapest thinking that Anatoly would want to do it in more than one site. Also, making the changes in the Navigation settings would break the site hierarchy connection, thogh it could be fixed back to what it was manually. – Marc D Anderson Oct 14 '11 at 19:40

If this is something you need to fit into a feature, you can use the following code within a feature receiver.

        using (SPWeb web = properties.Feature.Parent as SPWeb)
            SPNavigationNodeCollection nodeCol = web.Navigation.QuickLaunch;
            foreach (SPNavigationNode node in nodeCol)
                if ((node.Title == "Libraries") || (node.Title == "Lists"))
| improve this answer | | | | |
  • Thanks. The problem is I still want to have the children nodes: library X, library Y, Tasks, Announcement. But not the headers... – Anatoly Mironov Sep 25 '11 at 5:23
  • @AnatolyMironov, then, you can iterate through the web.Lists.Cast<SPList>().Where(l => l.OnQuickLaunch) and readd the links manually, using web.Navigation.QuickLaunch.Add method. Code approach is very flexible IMO and rather obvious in implementation. I don't see any problem here :) – Andrey Markeev Sep 25 '11 at 10:51
  • @omlin, what happens if a new lib is added? It won't be in the quiclaunch, will it? – Anatoly Mironov Sep 25 '11 at 15:59
  • @AnatolyMironov, the Libraries (or Lists, correspondingly) category will be recreated and the link will be placed there. Yes, that's right, this approach will not fix new created libs. If you really need this behavour, you could probably assign event receivers for all the lists, but I'm afraid that would be awkward and can't garantee that it will eventually work. So, maybe, really, some dirty js hacks will help you :) The trick is to hide header nodes, then take their children and move them one level up in the DOM hierarchy. As Marc mentioned, that is probably the cheapest way. – Andrey Markeev Sep 26 '11 at 5:19

Can you just edit the quicklaunch under site settings and remove the header?

| improve this answer | | | | |
  • The users should be able to create many such spwebs without editing site settings. – Anatoly Mironov Sep 25 '11 at 5:24

Your Answer

