I found
this in the 6.x forums, which shows the behavior in a CMSListMenu, but I'm also seeing it when dealing with TreeProvider.SelectNodes, directly.
It seems that when multiple document types are involved, the code is either generating more than one query, then concatenating the results, or is first ordering by ClassName.
This is my code:
protected void RenderNavigation(string section) {
NodeSelectionParameters navParams = new NodeSelectionParameters();
navParams.AliasPath = "/FPCEvents/" + section + "/%";
// Same behavior regardless of which ClassNames directive I use
//navParams.ClassNames = "CMS.MenuItem;CMS.Folder";
navParams.ClassNames = "*";
navParams.MaxRelativeLevel = 1;
// Same behavior even when "NodeLevel, NodeOrder, NodeName" is used
navParams.OrderBy = "NodeOrder";
navParams.SelectOnlyPublished = true;
navParams.Where = "DocumentMenuItemHideInNavigation = 0";
// create a TreeProvider instance
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
TreeProvider tree = new TreeProvider(ui);
TreeNodeDataSet ds = tree.SelectNodes(navParams);
foreach (TreeNode node in ds) {
string href = "/Subsite/" + section + "/" + node.NodeAlias;
navLeft.InnerHtml += "<li><a href=\"" + href + "\">" +
(node.DocumentMenuCaption == string.Empty ? node.DocumentName : node.DocumentMenuCaption) + "</a></li>";
}
}
(Yes, it does pretty much the same thing that CMSListMenu does. However, due to the structure of my site, CMSListMenu was not adequate, so I did this. It works, except for the order of the links generated.)
I have the following structure in CMSDesk:
Subsite
- Folder
- Page
- Page
- Folder
- Page
- Page
What the code generates:
- Folder
- Folder
- Page
- Page
- Page
- Page
It seems this behavior was fixed for CMSListMenu for version 7, so is there a way I can mimic the desired (CMSListMenu) behavior for ordering in my custom code?