Wednesday, November 5, 2014

Basic item style for CQWP

CQWP uses ItemStyle.xsl file which is located in the site collection's Style Library. By editing the ItemStyle.xsl file, we can add a custom item style, which can be selected from CQWP to show all the Vendors List fields with headings.



  1. Open the site collection URL
  2. Replace the /SitePages/Home.aspx with /Style%20Library/Forms/AllItems.aspx to open the Styles Library.
  3. Now it will show the following list of folders. Open the XSL Style Sheets folder to view the Itemstyle.xsl file.  
  4. Download the ItemStyle.xsl file to your computer
  5. Open it in a notepad and Scroll down to the bottom of the file. Now Copy the following code block and paste it above the closing xsl:stylesheet tag. Here the first HTML Table row represents the column headings and the second HTML table row represents the actual data.






<xsl:template name="CustomStyle" match="Row[@Style='CustomStyle']" mode="itemstyle">
    <html>
    <table width="100%">
   
    <tr>
        <td width="8%" valign="top"><div class="item"><xsl:value-of select="@Title" /></div></td>
     
    </tr>
    </table>
    </html>
  </xsl:template>

Friday, September 12, 2014



Content query web part all fields internal name



My times developers face problems in setting up the content query web part with the column names. use the below template in itemstyle.xsl and you can find out all the column name and then use the column name in the CQWP(content query web part) properties



  <xsl:template name="ViewFields" match="Row[@Style='ViewFields']" mode="itemstyle">
<xsl:for-each select="@*">
          P: <xsl:value-of select="name()" />
</xsl:for-each>
    </xsl:template>