Archive

Archive for the ‘DVWP’ Category

DVWP – quick tip for new items

31/01/2011 2 comments

Further to my earlier blog post about formatting the dates in the DVWP, I had another requirement to highlight the new content that was being rolled up.  Here, we had 2 options:

  1. Apply some conditional formatting to the @Title field.
  2. Utilise the !New icon that’s included in SharePoint OOB.

For us, the !New icon was the way to go but this posed a small problem.  If you create a new list item, you will see the !New icon there and then:

New Icon

However, when this list item is rolled up into the DVWP, that icon magically disappears.

Missing Icon

The solution is really very simple:

Fire up SharePoint Designer and browse to your web part page.  Position your pointer where you wish to display the !New icon and go into the code view.

Enter in the following code: <xsl:if test=”ddwrt:IfNew(string(@Created))”><img src=”/_layouts/1033/images/new.gif” alt=”New” border=”0″ /></xsl:if> and save the page.

Now when you create a new list item, it will display the !New icon in your DVWP – easy!

Icon restored

Categories: DVWP, SharePoint

Date formatting in DVWPs – Quick Tip

I’ve been working a lot lately on the DVWP in SharePoint Designer and have found that when you add in a date field, it will render in mm/dd/yyyy by default.  Now this is fine if you are in America but for us over here in the UK, we prefer the dd/mm/yyyy format.

To make the change, we need to highlight the date field in our DVWP and go into the Code view.  There you will see the default format code of 1033 (as shown below) – you simply need to change 1033 to 2057 and save

<xsl:value-of select=”ddwrt:FormatDate(string(@Created) , 1033 ,1)” />

For a list of all the codes available, click here

PS. Thanks to @sympmarc and @jbhoward for all their help in my DVWP journey thus far 🙂

 

Categories: DVWP, SharePoint