I have an Umbraco V4 website and I have the following code to list some documents (the code lists a link to the document property of a child page). I want to be able to add an icon next to the link such as a PDF or Word icon depending on what type of document it is. I was thinking I could add a couple of IF statements into my code to check what the file extension of the file is but I'm not sure what I need to test for. Can anyone give me any pointers or is this the wrong way to go about this?:
<xsl:if test="TEST FOR PDF EXTENSION"> <img src="/images/pdf-icon.jpg"/> </xsl:if> <xsl:if test="TEST FOR WORD EXTENSION"> <img src="/images/word-icon.jpg"/> </xsl:if>
Thanks for the repsonses, I have gone with Dirk's suggestion using jquery which works really nicely and from an accessibility point of view these icons are not critical so if someone is using a browser without script enabled then it doesn't really matter that they will not see the icons.
Add document icon automatically
Hi all,
I have an Umbraco V4 website and I have the following code to list some documents (the code lists a link to the document property of a child page). I want to be able to add an icon next to the link such as a PDF or Word icon depending on what type of document it is. I was thinking I could add a couple of IF statements into my code to check what the file extension of the file is but I'm not sure what I need to test for. Can anyone give me any pointers or is this the wrong way to go about this?:
Hi,
Each media file gets a umbracoExtension property, so you can check for that! Or, if you don't mind using jquery, here's a great example of setting the document icon.
Hope this helps.
Regards,
/Dirk
Also see the bottom of this post http://our.umbraco.org/forum/using/ui-questions/5550-best-practice-for-listing-download-files?p=0, and http://our.umbraco.org/forum/developers/xslt/2817-How-could-I-display-different-icons-for-different-file-types for two non-js dependent ideas
Dan
Hi Dirk and Dan,
Thanks for the repsonses, I have gone with Dirk's suggestion using jquery which works really nicely and from an accessibility point of view these icons are not critical so if someone is using a browser without script enabled then it doesn't really matter that they will not see the icons.
is working on a reply...