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 |
- The Document Icon must display the file-specific icon, but the hyperlink must point to the file.
- The Name field should display the document’s name, but without the file extension [Go here to find out how I accomplished displaying the name without the extension]
- Only the last 30 days of modified files should be displayed. [Go here to find out how I accomplished the filter]
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>
0 comments:
Post a Comment