Quantcast
Channel: Tallan's Technology Blog »» Web Parts - Tallan's Technology Blog
Viewing all articles
Browse latest Browse all 5

Displaying Enhanced Rich Text in Content Query Web Part

$
0
0

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:

Content Query displaying a RichText Encoded field.

Content Query displaying a RichText Encoded field.

Not exactly what I was looking for, but it turns out there’s a pretty quick and simple fix for this.

  1.  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.
  2. 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>
  3. Save the file and upload it back into the Style Library > XSL Style Sheets SharePoint Folder.
  4. Make sure to publish the file after you’ve uploaded it

Your Content Query web part should now display Enhanced Rich Text fields correctly.

Content Query displaying a decoded RichText field.

Content Query displaying a decoded RichText field.


Viewing all articles
Browse latest Browse all 5

Trending Articles