Displaying Enhanced Rich Text in Content Query Web Part
SharePoint has the Content Query web part, which is a control that allows a user to display an aggregated list of items based on some criteria. You can choose to return items from all sites within a site collection or from a specific list; all based on a list type and content type. You also get a few different display options, but if you try to return an Enhanced Rich Text field, that is to say some HTML and CSS Styling, the results are a bit funky. The HTML markup is actually encoded, so you get something like this:
Not exactly what I was looking for, but it turns out there’s a pretty quick and simple fix for this.
- In the site you are adding the Content Query web part go to Site Contents > Style Library > XSL Style Sheets and download a copy of ItemStyle.xsl.
- Open up ItemStyle.xsl in your favorite text editor and find all instances of the following:
<div class="description"> <xsl:value-of select="@Description"/> </div>
And replace them with:
<div class="description"> <xsl:value-of disable-output-escaping="yes" select="@Description"/> </div>
- Save the file and upload it back into the Style Library > XSL Style Sheets SharePoint Folder.
- Make sure to publish the file after you’ve uploaded it
Your Content Query web part should now display Enhanced Rich Text fields correctly.