Modifying the quick launch on FeatureActivated RRS feed

  • Question

  • Hello

    I have a small workspace site with pre-defined structure, a couple of web parts and so on. Now I would like (read i MUST find a way) to build a small quick launch per each workspace. There will be some links (say 10) of them.

    I have harvested net, but though I think everything should be OK, my code just doesn't start to work. The quick launch doesn't get anything inside. I can set it up by hand in site settings, anyhow, so the web template or master page shouldn't be the problem.

    Here is the code snippet from the eature activated method:

            thisWeb.AllowUnsafeUpdates = true;
            SPNavigationNodeCollection nodes = thisWeb.Navigation.QuickLaunch;
            SPNavigationNode menu_b = new SPNavigationNode("Tasks","Lists/Tasklist");

    The link in SPNavigationNode menu_b isn't what it will be in the final solution, I try just now to get something to the quick launch. I have also tried the other syntax for SPNavigationNode-constructor (with boolean if it is a local or external target) as well as nodes.AddAsLast(menu_b) (without that [indexed].Children construct, but things happen just the same with these alterations.

    Sharepoint Publishing is enabled if it matters (might matter, according some question without answer I found out)

    Anybody with any hint?


    Friday, April 1, 2011 4:05 PM


  • Sorry for bother, I found the light myself :)

    It goes quite differently when a publishing web, so here is the code that works now...

            thisWeb.AllowUnsafeUpdates = true;
            SPNavigationNode SPNode = SPNavigationSiteMapNode.CreateSPNavigationNode("Test", "http://www.google.com", NodeTypes.AuthoredLinkPlain, thisWeb.Navigation.QuickLaunch);
            thisWeb.AllowUnsafeUpdates = false;

     br, hank

    • Marked as answer by szd55 Friday, April 1, 2011 5:23 PM
    Friday, April 1, 2011 5:23 PM