The “New!” Icon in a Data View Web Part
When new items are added to lists and libraries in SharePoint, a cute little icon appears next to each list item for 2 days after the creation date. When a data view web part is created, this icon does not exist by default, so it needs to be added back. Here are the steps for adding the New icon back, and how to configure it so that it displays only when items are new, as usual.
In a regular list view, take a look at the a list, so that the location of this icon may be grabbed. Here, I’ll do it for you. I right-clicked on the New icon, and copied the following part of the icon’s URL (in WSS 3.0):
This image exists on the server, so we can simply reference that image, without having to make a copy of it in a site image library.
Now that the icon’s location has been obtained, it can be inserted into the data view web part. In this example, there is a library with company policies in it. Put a space after the document name, and insert the image. The page will look like this, with the New icon next to each item in the list:
Notice that the page is displayed in split view, and note that the URL to the image is the same one that we just obtained.
Next, conditional formatting will be used in order to further customize the New button. At the top of the screen, click the <Data View> menu, and choose <Conditional Formatting>. This will display the Conditional Formatting pane on the right side of the screen.
Click to select any one of the icons. In the Conditional Formatting pane, click the <Create> button, and choose <Show Content…>.
On the Condition Criteria screen, click the <Advanced…> button.
In the “Select a function category” drop-down box, choose “All”.
Double-click on IfNew, to add it to the expression box. Create the expression as shown in the above screenshot. When the expression has been created, notice the Preview section at the bottom. All of the trues and falses represent the items in the document library, whether this item will be displayed next to them or not. Click OK. Click OK again.
Now, only the new items will have this icon displayed next to them. There’s your default list view functionality back!
There’s another cool thing that can be done with IfNew. Not just the Created field, but ANY date field in the list can be used in this expression. There could be a special icon that says “Modified”, and it could be inserted in the list, only to be displayed next to items that have been modified in the past couple of days.
In the following example, I created a custom field called “Due Date”. With a custom icon, and the expression in place with “Due Date” instead of “Created”, these icons will automatically display next to items whose due dates are within the next couple of days.
Where does this “2 days” thing come from, anyway? It is a setting at the web application level, and can be changed with the following stsadm command:
stsadm.exe -o setproperty -propertyname days-to-show-new-icon -propertyvalue [days the icon will be visible] -url [web app URL]
The video of this method is shown here:
This can also be done in the content query webpart (for MOSS 2007) which results in non customized pages.. If you are interested in doing this the best example I can find is here: http://is.gd/5a7sG – Still pretty simple and effective in terms of what can be done with it. Great post Laura! 🙂
You helped me once again with a difficult story. I was able to recreate the new icon and used the modified field so the users can see what has been changed. Once again! thank you.
Hello, I am currently running into an issue with that New icon. When i use the original ListViewWebPart, the icon appears correctly depending on the property set with the stsadm command, for which i can specify any amount of duration. But as soon as i use a DataFormWebPart, the duration seem to be stuck for 2 days. Did i miss something? or does the “ifNew” tag not work with the stsadm property? Thank you for your help, Regards, Gael.
I hope you can help me. I have been searching for a way to display the new button in a list pulled in from another site, so I was so happy when I found your post. I had it working (saw the new button on everything in the list) until I did the conditional formatting, then I lost the new button completley. Here is a snippet of my code. Please let me know if you can see what I am doing wrong. Thank you. ms-alternating
When I come across issues like that, I usually just play with different settings and syntaxes until it looks right.