Question

enter image description hereUsing SharePoint 2010, Having Custom List With 4 Columns, Now I am Using Content Query Web-part To Display List Data ,But Currently It Display Only First Column, SO How to Display Custom Fields in a SharePoint 2010 Content By Query Web Part

Was it helpful?

Solution 2

1)Open ItemStyle.xsl

2)Add Template just like DisplayTemplate And give Proper Name(Currently given Name='MyFirst')

3)Add Variable After name="DisplayTitle"/> Currently i have two Columns MobileNo And Address

4)At The End of Code Add span

select="$MobileNo"

select="$Address"

5)Save ItemStyle.xsl and Checkin

6)Click on Edit WebPart ->Presentation->Fields to display: Here u can See Your Custom Column MobileNo & Address

Enter internal Name Of Column MobileNo inside MobileNo Custom Columns & Enter internal Name Of Column Address inside Address Custom Columns.

7)Click Ok

8)Done,now u can see all Custom Columns Data

u can see Total Code Below.(xsl:template name="MyFirst")

    <xsl:variable name="MobileNo"><xsl:value-of select="@MobileNo"></xsl:value-of></xsl:variable>
    <xsl:variable name="Address"><xsl:value-of select="@Address"></xsl:value-of></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> - <span><xsl:value-of select="$MobileNo"></xsl:value-of></span>
    <span><xsl:value-of select="$Address"></xsl:value-of></span>

  </div>
</xsl:template>

OTHER TIPS

A Content By Query Web Part displays a dynamic view of content on a page

  • The Web Part has two major aspects: query and presentation. Query determines what content you want to show and presentation determines how you want to style and present the content.

The Content By Query Web Part uses XSL style sheets to render these columns by default.

  • If you want to query for custom content types and render specific columns from those content types in the Web Part, you must perform some minor customization in the .webpart file.

  • Edit the properties in the Web Part file to display custom fields. To access the .webpart file for the Web Part, on the Web Part's Edit menu, click Export.

  • In the .webpart file, locate the CommonViewFields property. Use this property to specify the additional fields that you want to display in the Web Part. Add the internal names of the columns and the type.

    property name="CommonViewFields" type="string">KB_x0020_Title,Text;Product;

  • This markup requests the Product column, to make the data in the columns available for rendering

  • Export the database to use it in your SharePoint

    -To change the presentation for given column you have to make changes in .xsl file

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top