1

I don't want to go through adding an additional feature to my project. I would like to get hold of the current navigation and re-order about 6 items. There are some items on the very bottom and they need to go to "Project" header section of the quick launch navigation (which already exists with other items in it). How to re-order some of the links thats on the bottom of the quick lunch to be in the "Project" header section? I added some publishing pages and those pages are on the bottom of the quick lunch. Now they need to be in the "Project" Node (alphabetically).

https://stackoverflow.com/questions/676155/how-to-access-the-sharepoint-spnavigationnode-quicklaunch-property

3
  • What is the question?
    – SPDoctor
    May 23, 2011 at 17:31
  • @spdoc: I edited my post to include question. Here is what I have so far. SPNavigationNodeCollection qlNodes = web.Navigation.QuickLaunch; foreach (SPNavigationNode thisNode in qlNodes) { if (thisNode.Title == "Westcoast Project") { } } May 23, 2011 at 17:57
  • @spEveryone: so no one?? May 24, 2011 at 4:58

1 Answer 1

1

If you have links under other headings that need to move under the Projects heading, then you can use the Move/MoveFirst/MoveLast methods of SPNavigationNode. Here is some pseudocode code:

EDIT: I have corrected this code and tested it to make sure it works:

int moveToHeadingIndex = 0;
var nodesToMove = new List<SPNavigationNode>();
int index = 0;
foreach (SPNavigationNode heading in web.Navigation.QuickLaunch)
{
  if (heading.Title == "Project")
  {
    moveToHeadingIndex = index;
  }
  else
  {
    foreach (SPNavigationNode child in heading.Children)
    {
      if (child.Title == "first page you want to move" ||
          child.Title == "second page you want to move" ||
          etc.)
      {
        nodesToMove.Add(child);
      }
    }
  }
  index++;
}
SPNavigationNodeCollection headingNodeCollection = web.Navigation.QuickLaunch[moveToHeadingIndex].Children;
foreach (SPNavigationNode node in nodesToMove)
{
  node.MoveToLast(headingNodeCollection);
}
2
  • Thanks, great. I can at least start someplace. Thanks again for your help. May 24, 2011 at 5:11
  • @Monica, I updated the code and tested to make sure it works.
    – Laurie
    Jun 2, 2011 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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