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 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).

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

share|improve this question
    
What is the question? –  SPDoctor May 23 '11 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") { } } –  Monica Contera May 23 '11 at 17:57
    
@spEveryone: so no one?? –  Monica Contera May 24 '11 at 4:58
add comment

1 Answer

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);
}
share|improve this answer
    
Thanks, great. I can at least start someplace. Thanks again for your help. –  Monica Contera May 24 '11 at 5:11
    
@Monica, I updated the code and tested to make sure it works. –  Laurie Jun 2 '11 at 2:53
add comment

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.