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: