To show the standard SharePoint icon against new list items in a data view web part (or other XSLT web parts), use the following snippet:
<xsl:if test="ddwrt:IfNew(string(@Created))">
<img src="/_layouts/1033/images/new.gif" alt="New" />
</xsl:if>
Tuesday, June 26, 2007
Subscribe to:
Post Comments (Atom)
10 comments:
You are my hero. I was searching for this exact information on the web - found some posts about displaying the document icon, but you were the only one I found to post about the "new" icon. Thank you so much!
Where does this code go?
Insert this code into the XSL of a data view (or data form) web part - this can be done using the code view of the page you are editing in SharePoint Designer.
The XSL of the web part defines what data fields will appear in what rendered HTML - you need to be able to be comfortable with understanding and editing XSL inside of SharePoint Designer to use the code in this post.
Thanks. Works great. Do you know of a way to lengthen the time to display the "New" icon without altering the server configuration...so I can have custom length for each list?
Karen, you could use some additional XSL handling to adjust the @Created date value in the "IfNew" ddwrt command.
For example, you could get today's date using
ddwrt:Today()
and use that to adjust the @Created date, or add some value to the @Created date inside the IfNew() method call using XSL functions. Here are some details of the ddwrt functions.
Thank you, thank you, thank you! Just what I was looking for.
Can it be added to the content query tool webpart? I have tried to implement it through the itemStyle.xsl but returned with error. Any ideas, please?
Sam
See this post on adding the !new tag to the CQWP - it's all about the namespace...
http://www.sharepointblogs.com/joed/archive/2008/02/03/display-a-quot-new-quot-indicator-in-the-content-query-web-part.aspx
This is ace, thanks so much for posting!
Post a Comment