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).
-
What is the question?– SPDoctorMay 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") { } }– Monica ConteraMay 23, 2011 at 17:57
-
@spEveryone: so no one??– Monica ConteraMay 24, 2011 at 4:58
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);
}
-
Thanks, great. I can at least start someplace. Thanks again for your help. May 24, 2011 at 5:11
-