0

Content query web part on a series of announcement lists.

disable-output-escaping="yes" does not work on the 'body' field

Any clue on why?

I have tried both on SP online and SP 2010 enterprise. I have added body to the CQWP modified and listed it as RichHTML

4
  • Check to make sure your custom template is being called. Can you post the code?
    – Aveenav
    Jul 20 '16 at 14:29
  • I have realized it is working if I set the template called 'NoImage' which strangely (and stupidly) it is called Title and Description in the dropdown. If I take that one and leave the field called 'description' and I type into it, body, then the disable-output-escaping works. If I change it to have body as the name of the field, it does not work. Do you know why?
    – susan
    Jul 20 '16 at 14:36
  • does it look like the following? <xsl:value-of disable-output-escaping="yes" select="@Body" />
    – Aveenav
    Jul 20 '16 at 15:06
  • Yes, that was my original, with @Description it works. I have already wrote the definition of 'Body' since in the same itemstyle file there is a modified template for a blog post (where body is still the body of the message)
    – susan
    Jul 20 '16 at 15:09
0

In your ItemStyle.xsl, create a new template and add this code. Make sure you publish it and select the template in the web part properties.

 <xsl:template name="Announcement" match="Row[@Style='Announcement']" mode="itemstyle">
      <xsl:variable name="SafeLinkUrl">
          <xsl:call-template name="OuterTemplate.GetSafeLink">
              <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="DisplayTitle">
          <xsl:call-template name="OuterTemplate.GetTitle">
              <xsl:with-param name="Title" select="@Title"/>
              <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
      </xsl:variable>
      <div class="item link-item">
          <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
          <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
            <xsl:if test="$ItemsHaveStreams = 'True'">
              <xsl:attribute name="onclick">
                <xsl:value-of select="@OnClickForWebRendering"/>
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
              <xsl:attribute name="onclick">
                <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
              </xsl:attribute>
            </xsl:if>
            <xsl:value-of select="$DisplayTitle"/>
          </a>
          <div class="description">
              <xsl:value-of select="@Description" />
            <xsl:value-of disable-output-escaping="yes" select="@Body" />
          </div>
      </div>
  </xsl:template>

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.