You need to sign in to do that
Don't have an account?
Updated: Dynamically display icon based on file type in Salesforce CRM Content
For some reason, my message body disappeared when I posted it.
I have created a Visualforce page that displays the documents in a specific Salesforce CRM Content Workspace. I used this cookbook article as a template: http://developer.force.com/cookbook/recipe/displaying-salesforce-crm-content-documents-in-a-visualforce-page. What I want to do is display an icon to represent the file type (determined by FileType field of ContentVersion object), or at least generate a more user friendly text label than the values that are in that field. I am stumped as to how to accomplish this in Visualforce/Apex. I thought I could create a method in my controller to return the name of an image file contained in a static resource, but I don't see how that could work. Any help will be appreciated.
So no one has any ideas?
Were you able to figure this out?
Yes. I created a wrapper class that wrapped the ContentVersion class and added the additional properties I needed. It looks like this:
I build a list of this class in my page controller:
Then I display it on my VisualForce page like this:
In my implementation, the table is sortable by each column. I did not include the code for that above.
Were you able to use the Salesforce icon library, or did you have to upload your own? If you used your own, where did you get it?
After doing a little research, I found out how to use the SFDC icons without having to create my own resource file. The icons are all stored in 1 PNG file, and they use CSS to determine which one to show. To make this work with my VF page, I just needed to link to just 1 CSS file. I modified your class to make it work.
VF page:
Nice. Thanks for the update.