SharePoint sub sites menu: the DataView strikes back...

SharePoint metro styled sub site menu

After 10 years working with SharePoint I should know better than to make an assumption like I did in my last post:

The web part could easily be changed to display subsites by switching the SPDataSource mode to Webs and using the web attributes.

In “easily” changing the DVWP demo to be a metro styled sub site menu, I came across a SharePoint 2010 bug that renders the SPDataSource Webs mode unusable. hmmm..

The Webs mode uses a list of SPWeb properties that are hard coded inside the Microsoft.SharePoint.WebControls.SPDataSourceViewResultItem class. The list includes an internal SPWeb property CustomizationMode that was present in 2007 and removed in SharePoint 2010. So when the SP2010 data source tries to get the value of the property it throws an exception “System.InvalidOperationException: The specified property name does not exist: __spCustomizationMode”.

Still, for those wanting the sub sites web part for SharePoint 2007 it’s available for download here for 2007 ONLY . The web part displays a link to the sub site with its title, last modified date and a small icon indicating the site type as above.

Sub sites XSL Template

The XSL template is similar to the list menu web part apart from the ordering is done on last modified date:

   order="descending" />

Also the display template for the tile changes include the correct icon for each sub site being calculated from its web template:

  <xsl:when test="@__spWebTemplate = 'MPS'">    
    <img src="/_layouts/images/mtgicon.gif" class="micon" />    
      <xsl:when test="@__spWebTemplate = 'STS' and 
                      @__spConfiguration = '2'">    
        <img src="/_layouts/images/docicon.gif" class="micon" />    
        <img src="/_layouts/images/stsicon.gif" class="micon" />    


Until (if?) the bug is fixed, use either the client side object model (check out the following post by Bil Simser - Metro Style Site Directory for SharePoint Using EMCAScript) or the search API as your data source for a site directory.

Email this · Tweet this · Share on Google+ · Share on Facebook · Post to · Subscribe to this feed


blog comments powered by Disqus