1

I have a Content Query Web Part added to a SharePoint 2010 site home page. I've got it set to pull in all Announcements from all sub sites. I've set the content to pull in the Body content of the individual announcement. It's pulling in the body, plus additional code. ![Additional code in CQWP][1] How can I get rid of the additional code? Thank you.

(images removed)

  • I suspect the CQWP is rendering the content in plain text and not rendering the HTML markup from the announcement itself, you might need to crack open the itemstyle.xsl file and manipulate it – Eric Alexander May 22 '15 at 15:05
2

Or you can just add disable-output-escaping="yes" to the xsl value in itemstyle.xsl to get the html to render correctly.

For example:

xsl:value-of select="substring(@Description,1,255)" disable-output-escaping="yes" />

OUTPUT ESCAPING RICH TEXT IN A CONTENT QUERY WEB PART

  • Thank you for your comment. Do you know where I would find the itemstyle.xsl file? Thanks! – Anonymous May 27 '15 at 13:08
  • Ah yes, it's located in the site collection / root site collection Style Library. My suggestion is to download a copy of it and not change the original file. – Christoffer May 27 '15 at 13:27
0

You can edit the XSLT and remove html using below template

<xsl:template name="RemoveHtml">
  <xsl:param name="String"/>
  <xsl:choose>
    <xsl:when test="contains($String, '&lt;')">
      <xsl:value-of select="substring-before($String, '&lt;')"/>
      <xsl:call-template name="RemoveHtml">
        <xsl:with-param name="String"
          select="substring-after($String, '&gt;')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$String"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

And call this using

<xsl:call-template name="RemoveHtml">
  <xsl:with-param name="String" select="@Description"/>
</xsl:call-template>

Source - http://blog.mastykarz.nl/remove-html-markup-content-query-web-part/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.