Show all subsites in a webpart

I’ve been looking for a while to find a webpart that would show all the subsites of a particular sharepoint site. If you google this, there appear to be lots of people looking for the same thing.

Well, I’ve just found an old reference which, a slight update for MOSS 2007 seems to work at a basic level. The source is: Show Sub Sites in WSS Sites but you have to look out for the “Attachment launch now!” bit. I’m going to repeat the relevant bit here but updated for 2007 (apologies if this is done elsewhere…)

Show sub sites in MOSS sites

You can use SharePoint Designer to show a list of sub sites in a MOSS site.

An example of a sub site is a document workspace. An overview of all available sub sites provides an easy way for users to navigate to these workspaces.

1) Open your site in SharePoint Designer

2) Open the Data Source Library task pane

3) Connect to the XML Web Service that provides information about the sub sites.

4) Add the information to your home page

You can drag and drop the newly created data source to your home page. A list of sub sites will be shown.

5) Change the way the information is shown.

By default a plain list of the sub sites will be shown. You can change this list, and for instance make the URL’s clickable. As you hover over the title field, right click and select:

  • Data Field: Title
  • Format as: Hyperlink

6) Amend the rest of the layout to suit your design.

 

That’s it – I’m no coder so this comes with all usual warnings but it seems to work for me.

24 Comments Add yours

  1. KellyB says:

    I tried this and it works for sites one level down, have you tried this to pick up subsites?

    Thanks.

  2. raj says:

    gr8 post

  3. Sebastian says:

    Thanks a lot – works great! Maybe one slight addition in Step five:

    Right click on “Title” choose: insert Hyperlink, then in the address field add: {@Url} and you will have the title as title and the URL as link. Looks a bit nicer I think.

    Cheers

  4. Tomas says:

    This is great, but it will only work for site members or higher. The web part breaks for visitors. Any suggestions?

    Is there a way for this web part to have security trimming? At the moment, it shows all sites regardless of users access rights.

  5. Tomas says:

    Hi, I have managed to get this working for all users by using a username and password on the datasource. But I am still coming to dead ends when trying to security trim the list. Can anyone help?

  6. Carmen says:

    How do I do # “4) Add the information to your home page?”

    1. Michael says:

      Hi Carmen –

      It’s been a while since I did this, but if I recall correctly, the data source appears in the list in the Data Source Library task pane on the right hand side of Sharepoint Designer. If I’m right, you just drag it from there onto your page.

  7. ben says:

    Sebastian :Thanks a lot – works great! Maybe one slight addition in Step five:
    Right click on “Title” choose: insert Hyperlink, then in the address field add: {@Url} and you will have the title as title and the URL as link. Looks a bit nicer I think.
    Cheers

    i have managed to get the list working but it doesnt re direct you to the site when you click on the site you want in the drop down.

  8. ram says:

    Hello,

    A good example to one of my issues. I implemented at my site following your steps. However now, after 2 weeks, the dataview shows an error message stating
    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator

    When I tried to look at the Datasource properties in SPD, everything looks the same except the Disconnect button under location changed to “Reconnect”. Not sure why, can someone help me please?

  9. Ryan says:

    Hi, the example is great and has helped me lots. I wonder if anyone has come across a problem I have with Alternate Access Mappings. If I create the webpart in SPD on the http://servername:port/ site and then navigate using this URL it works fine. However if I navigate to the exact same site using http://niceeasyurl the webpart displays the error “Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.”

    Any thoughts?

  10. Tracy says:

    I’m a bit of a novice when it comes to Designer, I’m afraid and consequently was unable to get this method to work. I published a web part to do what I needed here: http://subsitelistwebpart.codeplex.com/.

    -Tracy

  11. Prakash JJ says:

    KellyB :I tried this and it works for sites one level down, have you tried this to pick up subsites?
    Thanks.

    It certainly does not pick sub-sites. Is there a work around this?

    1. Esther says:

      Hi there,
      to get all subsites (nested), use the GetAllSubWebs method from the webs web service

  12. nitin says:

    Great post. Helped me most when I was looking for something similar.

    Cheers!

  13. Patrick says:

    Hey,

    Wonderful post, thanks a lot for this! I was actually wondering if you know of an easy way to save this ‘configuration’ as a webpart that I can add to the gallery, so I don’t have to do this via SPD every time someone wants a subsite listing added?

    All the best,
    Patrick

  14. phils says:

    Interesting however it does not work for me. Everything is fine up to step 4. When I drag it onto the page it shows nothing and on the Data Source Details pane it says “The server returned a non-specific error when trying to get data from the data source….”

  15. Patrick says:

    It returned the same error for me. In order to test I entered my site username and password directly and it loaded the correct data. On the site it actually did show the correct site listing for those sites users are authorised to see. In SPD it only worked for me if I entered my username and password directly, which was fine b/c I just removed my credentials after test.

  16. Shivani Patel says:

    how can we make this work in SPD 2010. I wasn’t able to find a ‘XML connection’ option.

    1. Yancy says:

      Alright alright alright that\’s exactly what I nedeed!

  17. SabbeRubbish says:

    For SharePoint 2010:
    Click on the “Data Sources” tab (on the left), then click on SOAP Service Connection. Use the same URL as stated above.
    Then, when editing a page, on the “Insert” tab, click on “Data View” and select the data source you just added.

    If you can’t follow just yet, let me know, I’ll blog about it then.

Leave a Reply

Your email address will not be published. Required fields are marked *