I have added Content query webpart in home page for announcement list.

I have a done changes in XSLT file to show body field. Now I want to add attachment field.

for body i used below code:

<div class="Body">
     <xsl:value-of disable-output-escaping="yes" select="@Body" />
  • Check this and let me know if it works for you. – Ganesh Sanap Jan 31 at 10:21

Try below code and see if it works for you:

<xsl:element name="SharePoint:AttachmentsField">
     <xsl:attribute name="runat">server</xsl:attribute>
     <xsl:attribute name="FieldName">Attachments</xsl:attribute>
     <xsl:attribute name="ControlMode">Display</xsl:attribute>
     <xsl:attribute name="Visible">true</xsl:attribute>
     <xsl:attribute name="ItemId">
          <xsl:value-of select="@ID"/>

Source: Attachments files on Content Query.

| improve this answer | |
  • Have you tried this solution? Please Upvote(^) and accept as an Answer if it helped you. – Ganesh Sanap Feb 3 at 13:57
  • This code is for List view I believe. How can we add this in Content Query WebPart. If I use attachments field, it show 1 or 0 depending on the number of attachments to the list item. – Farhan Feb 10 at 8:45

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.