Posts

Showing posts with the label xslt

SharePoint - Write XSLT getting icon image for attachment link

I created an event receiver in MOSS that oncreate and onupdate item, save link of Attachment in a HyperLink Field, named Link1. So I have a list of items, with direct link to document in attachment. In web part, I want to show Icon of type of document, in the first column. But there is no function to get "last index of" dot, in extension of file. So I created the script below, getting last 5 chars in link (probably, the dot and the extension, as ".pptx"): <img src='{concat('/_layouts/images/ic',substring-after( substring(substring-before(@Link1,','),string-length(substring-before(@Link1,','))-4,6),'.'),'.gif')}' /> So, if attachment is a 'pdf' file, it search for image at url "/layouts/images/icpdf.gif". Of course, you have all icon image in /layouts/images, or you can create your custom folder for icons!