SharePoint Designer 2010– Custom XSLT

Using SharePoint Designer 2010 you can create nice looking user interface renderings of data stored within lists and libraries without any custom coding by replacing the out of the box XSLT with your own custom XSLT.   To get started, you need to take a couple simple steps to enable this advanced functionality in SharePoint Designer.

  1. Open a site in SharePoint Designer.   You will need at least one web part page available in order to create a web part with custom XSLT.   If you are in a publishing site you will need to create a web part page because you cannot edit the content of a publishing page using SharePoint Designer.
  2. Locate your test web part page and open it for editing in SharePoint Designer.
  3. On the Home tab click on the Advanced Mode button in the ribbon bar.
  4. Click in a web part zone and then from the insert tab select the Data View drop down and choose the list or library you wish to use as your data source.
  5. Select the newly created web part and in the Design tab under the List View Tools grouping, click on the Customize XSLT drop down and select Customize Entire View.
  6. You can now switch to the code view for the page and modify the XSL.
  7. Once you have finished modifying your web part you can save the page and then export your web part.   This new web part can be used anywhere within the site that contains the source data list or library.

Based upon my testing you must include the following in your XSL or you will receive an “Unable to display this Web Part” error.

<xsl:include href=”/_layouts/xsl/main.xsl” />

SharePoint uses the main.xsl as the core XSL file for providing the defaul schema independent rendering of list and library views.   Even if you are writing your own XSL it appears that SharePoint still needs access to pieces of that XML.

0 thoughts on “SharePoint Designer 2010– Custom XSLT”

  1. After highlighting a column in the xsltlistviewwebpart, I click on Customize XSLT > Customize Entire View. I try to format a datetime column which it does, but when I save it loses changes. Why is this so difficult in 2010 when 2007 was so easy?

    1. I am assuming your are trying to edit a web part that is in a SharePoint 2010 team site. If so, make sure you are editing the correct page. If you are using the new SharePoint 2010 team sites the home page is actually located under the site pages folder. The “default.aspx” page that is at the root of the site is not the correct file to edit, by default it is the “home.aspx” page located under the site pages library.

  2. @machewd and @Emanon

    To persist your changes you must make sure to remove the “ddwrt:ghost” attribute from the element. The ””ghost”” attribute is used to mark any xslt that sharepoint considers static and, therefore, will not accept any changes to. When you remove the ghost attribute, your changes should be persisted.

  3. Can anyone point me at some good sites to help with stage 6 🙂

    Not so much to understand XSLT in general, but to understand how this particular webpart works, and the best ways of modifying it.

  4. Very helpfull – thankyou.

    When we customise stylesheets we pull out the stylesheets and put them in a Syle library. To do this locate the begin/end of the xsl (Starting with <xsl:stylesheet xmlns:x="😉 – about 1700 lines! and copy it to notepad. Then save it to a file and upload to a style library. You can then edit each webpart which references the list you are interested in from sharepoint and put the URL of the Style item into the Miscelaneous / XSL box on each web part.
    Makes maintaing things a bit easier

  5. Hi, How about discussion boards XSL in SharePoint 2010. I am trying to sort the Flat View and it staples Name & Subject on Top of the Posts. When i am trying to sort it does not change the way it used to be on MOSS 2007. Any suggestion will help. Thank you

Leave a Reply