Scenario:
With in Content Query Webpart you want to display a message text next to the items depending upon one of the other column value.
Explaination:
(A). Content Query Webpart uses templates defined in ItemStyle.xsl file to determine the layout and appearance of the Items, so add a new Item Style template to display the message from the required column.
(B). By Default Content Query Webpart exposes certain columns and we need to modify it to be able to pull any additional Columns ( Legal column in my case ).
Steps for (A):
1. Navigate to top level site collection
2. Click on all Items
3. Open "Style Library"
4. Open "XSL Style Sheets"
5. Check-out ItemStyle.xsl
6. Add the Template as given below
7. Check-in the ItemStyle.xsl
ItemStyle Template:
<xsl:template name="NewTemplate" match="Row[@Style='NewTemplate']" 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="Url" select="@LinkUrl"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div id="linkitem" class="item">
<div class="link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}" >
<xsl:value-of select="$DisplayTitle"/>
</a>
<xsl:if test="string-length(@Modified) != 0">
<font color="red" size="1" >
( <i><xsl:value-of select="@Modified"/></i> )
</font>
</xsl:if>
</div>
</div>
</xsl:template>
Steps for (B):
1. Navigate to the site.
2. Edit the page.
3. Add a Content Query Webpart and click "Modify Shared Webpart".
4. Modify options to display items from document library having the "Modified" column.
5. Go to Presentation section and Select "NewTemplate" as ItemStyle.
6. Click 'OK'
7. Export the webpart now and save the file on your Desktop
8. Open the file with Visual Studio or Notepad
9. Search for "CommonViewFields" tag
9. Add the Modified column as shown
<property name="CommonViewFields" type="string" >Modified</property>
10. Save the file and exit
11.Import the new Webpart into SharePoint site
12.Drop it to any page and you can see the tagging.
0 comments:
Post a Comment