Custom Filter on a Data View Web Part (series part 3)

Data Views can be a very powerful tool when using SharePoint Designer 2007 in designing pages in your WSS 3.0 and MOSS 2007 environments (the same is true for SharePoint Designer 2010 and SharePoint 2010).
One of the requirements for my project is to display documents from two different SharePoint Document Libraries in one view and have the documents displayed in a specific way. The content is to be displayed in the table view as follows:

Document Icon Name Title Modified Date

To filter the list of items in the Data View, first I setup the Data View to display the content like I wanted. Then, selecting the Common Data View Tasks drop-down (as shown below), I selected the Filter: option.

tasks

The expression is pretty involved, but I cheated a little by using the Filter Criteria option. The expression I started off with was Modified Is Greater or Equal To [Current Date], as shown below.

basicexpress

I then selected the Advanced button (shown on the picture above) and I was presented with the advanced expression being used by the builder. I added “- 30” without the quotes to the expression.

expressionbuilder2

The whole expression ended up being the one shown below:
[number(translate(substring-before(@Modified,’T’),’-‘,”)) >= number(translate(substring-before($Today,’T’),’-‘,”)) -30]

Custom Column Data Display Names Using a Data View Web Part (series part 2)

Data Views can be a very powerful tool when using SharePoint Designer 2007 in designing pages in your WSS 3.0 and MOSS 2007 environments (the same is true for SharePoint Designer 2010 and SharePoint 2010).
One of the requirements for my project is to display documents from two different SharePoint Document Libraries in one view and have the documents displayed in a specific way. The content is to be displayed in the table view as follows:

Document Icon Name Title Modified Date

To show the name without the file extension, I added the Name field to the table, then converted the value to a Hyperlink. I then made the hyperlink value point to the file using @FileRef.

To remove the extension from the display, I built the display value using two different expressions, as shown below:
substring-before(string(@FileLeafRef), ‘.’)

full

Working from the inside out, ‘string’ converts the filename variable into a string so the next expression can work with the value. ‘Substring-before’ accepts two variables: the data value and what character to look at for stopping (which is the period ‘.’).

So, the full URL looks like: <a href=”{@FileRef}”><xsl:value-of select=”substring-before(string(@FileLeafRef), ‘.’)” /></a>

Custom Document Icon Using a Data View Web Part (series part 1)

Data Views can be a very powerful tool when using SharePoint Designer 2007 in designing pages in your WSS 3.0 and MOSS 2007 environments (the same is true for SharePoint Designer 2010 and SharePoint 2010).
One of the requirements for my project is to display documents from two different SharePoint Document Libraries in one view and have the documents displayed in a specific way. The content is to be displayed in the table view as follows:

Document Icon Name Title Modified Date

To show the Document Icon, I added the DocIcon field to the table, then converted the value to a Hyperlink. I then made the hyperlink value point to the file using @FileRef.
To point the DocIcon (which has a value of ‘PDF’, since all my documents were PDFs) link to the correct picture, I pointed to a pdf picture (pdf.gif) on my site. You could do this several ways, but I just put a PDF icon in a ‘system’ document library on my site. I also wanted to make my solution work if it was later decided to add documents to the displayed libraries that were a different type other than PDF.

So, in the hyperlink, I used the @DocIcon field in the src value:
src=”/site/system/{@DocIcon}.gif width =”17” height=”17”

A couple things to note about the link above: 1) it assumes all the images will be gifs and will reside in the same document library and 2) the images are all shown with 17 pixel width and height.

So, the full URL looks like: <a href=”{@FileRef}”><img border=”0” src=”/site/system/{@DocIcon}.gif width =”17” height=”17” /></a>