thank you for reading my question.
Following situation:
-A sharepoint list, based on a custom content type. The content type is nothing more than a folder with some extra properties (like url, targetpage).
-The folder content types and items represent a menu structure. For example:
Home | www.home.com | home.aspx
---> Subhome | www.subhome.com | subhome.aspx
Impressum | www.impressum.com | impressum.aspx
This structure has no limits how deep it's going to be or how many items/folders it can contain. The only restriction is that inside a folder every name must be unique.
Because of the performance I need to fetch all items in the list at once and not for every folder. I managed it this way:
SPQuery qry = new SPQuery();
qry.ViewAttributes = "Scope='RecursiveAll'";
After that I translate the SPListItems into an object called NavigationEntry. This object contains an SiteMapNode and some other properties like the path, itemname and levelcount (e.g. Home/Subhome = level2, Impressum = level1).
Now I place all this items in a dictionary with the path+itemname as key (because it's unique and gives me a hint where the item lies). After that I access this dictionary with linq and grab the items level per level until I reach the end (no items available on a level). Now comes the tricky part. I have to "convert" this weird structure into navigation structure for sharpoint. Because i'm new to sharepoint this is a bit confusing sometimes.
At the moment I go trough the levels and create SiteMapNodes with SiteMapNodeCollections, go to the next level, look if the parentitem is already there, put the child into it and so on. That works, but its very complicated, dirty and fragil.
Is there any "easy" or more structured way to solve this issue? I'm not looking for an already coded solution but for any hint into the right direction on how to solve this. Thank you! :)
IF just an Navigation tree is what you want , I can recomment JSTree
I once used it for a multilevel Quichnav Delegate. While I made a Manage Interface to add items, You could just cunstruct a XML or Json in the Change Events of the List. Or to be more fancy do a query every time a node is expanded.
Hope this helps
Lars