Monday, July 27, 2009

How to add a new indicator in a Content Query Web Part

Content Query web part doesn't show New! status indicator for new items by
default.

In order to add new indicator a customization of content query web part will be
required.

Following steps define the process for adding new container

1. Open SharePoint Designer and connect to your site


2. Browse to following path from SharePoint Designer
StyleLibrary->XSL Style Sheets->Item Style.xsl


3. Above xsl contains style templaes that can be selected from Content Query web
part's properties. You need to implement your custom template.


4. Copy any suitable template that can become base for your custom style. I
would prefer to copy default template

5. Paste template at the end of file before </xsl:stylesheet> end tag

6. Change name to your style name e.g. CustomStyle and match to custom style
e.g. Row[@Style='CustomStyle']

7. Need to add following declaration at top of the file with other declarations

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

8. search following at you custom template

<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">

<xsl:value-of select="$DisplayTitle"/>

</a>

and replace with

<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">

<xsl:value-of select="$DisplayTitle"/>

</a>

<xsl:if test="ddwrt:IfNew(string(@Created))">

<img src="/_layouts/1033/images/new.gif" alt="New" />

</xsl:if>

9. Publish file

10. Open your page with content query webpart and select custom style created in
last step

No comments:

Post a Comment