Sitefinity makes it easy to add a sitemap control to your site. Simply drop the Site Treeview control from the Navigation control group onto your page. However a problem remains. The nodes of the the sitemap tree are collapsed and not expanded as one would expect. And there is no property around that would automatically display the tree view with all nodes expanded.
Of course you can create a custom control and implement the desired behaviour with only a few lines of code. But uploading the control, registering it within the web config file is quite a big hassle for such a small feature. If you do not share my opinion you can download such a control from Sitefinity CMS Marketplace, but if you want another solution keep on reading.
Here is how you do it:
- Add a Generic Content Control
- Switch to edit mode and select the HTML tab to enter the following lines
function ExpandNodes(sender, eventArgs)
var tree = sender;
var nodes = tree.get_allNodes();
for (var i=0; i<nodes.length;i++)
- Save the changes. (You won't see anything as you added some javsascript code.)
- Next add a Site Treeview Control to the page.
- Switch to edit mode and navigate to the Misc section.
- Click the Edit button of the TreeView property.
- Navigate to the Client Side Events section.
- Add the following text to the OnClientLoad property: ExpandNodes
- Click the I'm done button to save the changes.
If you followed the instructions correctly the treeview should already be displayed with all nodes expanded.