SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Custom Content Types with Custom Icons

   

We found an interesting problem with associating a custom icon with our file format to a custom Content Type. Let me try to explain.

 Suppose we have a file format with a .tjc extension. (.tjc is just a made up file extension as an example)

If we upload a sample file, "sample.tjc", to a standard team site, the document is shown with a generic icon, which is defined by the default mapping element inside of 12Hive\Template\XML\Docicon.XML. This happens because we did not specify a file extension mapping for the .tjc file extension in the docicon.xml file

   

<DocIcons>

...

<Default>

<Mapping Value="icgen.gif"/>

</Default>

</DocIcons>

   

To associate the "TJC" file extension with a custom icon, we add the following line to the DOCICON.XML file, and perform an iisreset.

<Mapping Key="tjc" Value="ictjc.gif" EditText="My Custom Document Editor"
OpenControl="MyCustomEditor.OpenDocuments" />

Simple.

But what if we want to associate this icon with a custom type?

We start by creating a New Content Type:

   

Upload a .tjc file as the new document template:

   

Under the Settings ->Document Library Settings--> Advanced Settings for my document library, and toggle on the Content Types -- Allow management of content types:

   

Then back on Document Library Settings page, I can add my custom Content Type, but clicking "Add from existing site content types:

   

And my custom Content type now appears in the list and should be visible on the new button.

   

But no icon appears:

The reason is the SharePoint code is looking for a larger version of the associated docicon.xml icon, and assumes that it similar names as the similar icon, but has a prepended "lg_" in front of it. In this example, it is looking for the file "lg_ictjc.gif".

   

Thus, we create a larger version of the icon,

and prepend the filename with "lg_" ,

add it to the 12Hive\Template\images directory,

refresh your web browser,

And the custom icon will then appear.

   

Couple of other notes:

  1. I f one use a custom Office document as your Content Type, it will just work without any modifications because both the small version and the large version of the icons already appear in the 12Hive\Template\Images directory.
  2. The size of the small icon is 16x16 pixels, 96x96 resolution and 8 bit color depth.
  3. The large icon should be 32 x32 pixels, 96x96 resolution and 8 bit color depth.
  4. If your small images are stored in a subfolder below images like this:

12Hive\Template\Images\MyCompany\ictjc.gif

   You will need to create an equivalent subfolder with a prepended "lg_" rather than the image filename itself:

12Hive\Template\Images\lg_MyCompany\ictjc.gif

   

More about the docicon.xml  file, can be found here:

http://msdn2.microsoft.com/en-us/library/ms463701.aspx

   

Hope this helps someone.

Tom   


Posted 08-24-2007 11:51 PM by tchmiel

Comments

Links (8/26/2007) « Steve Pietrek’s SharePoint Stuff wrote Links (8/26/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff
on 08-26-2007 6:46 PM

Pingback from  Links (8/26/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

15 Links Today (2007-08-27) wrote 15 Links Today (2007-08-27)
on 08-27-2007 10:20 AM

Pingback from  15 Links Today (2007-08-27)

EddieV wrote re: Custom Content Types with Custom Icons
on 11-28-2007 9:01 AM

Hello

I have all my icons displaying in my document libraries and i got the pdf icon to work as well, but everyday i have to reset IIS 6 to have the icons reappear. Do you know what might be causing this and how do i correct this?

Thank you

tchmiel wrote re: Custom Content Types with Custom Icons
on 11-29-2007 5:35 PM

@EddieV - Sorry, I have never seen this behavior before. Sounds like a page caching problem.  Sorry I can't really help.  Have you tried creating a new site after the icons are installed, and do you still have the problem there?

Casey Hanks wrote re: Custom Content Types with Custom Icons
on 03-27-2008 8:09 AM

From your article I am hoping that you might have some experience with creating a custom version of the SharePoint.OpenDocuments ActiveX control

This article gives hints about how to accomplish this:

msdn2.microsoft.com/.../aa978104.aspx  (tells how to do everything except created the custom ActiveX control)

Do you have sample code showing an ActiveX control that implements the interfaces of the SharePoint.OpenDocuments class

Thanks,

Casey Hanks

c.hanks@InfoAssure.net

(443) 837-2221

tchmiel wrote re: Custom Content Types with Custom Icons
on 03-27-2008 8:44 AM

@Casey

take at look at

www.codeplex.com/sharepad

This is where we started from. This is based on Sharepoint 2003 interfaces and has not been updated to support the 2007 interfaces.  

tchmiel wrote re: Custom Content Types with Custom Icons
on 06-04-2008 3:59 PM

@Brian,

No, not really.  My guess is that you would create a custom view using CAML and then conditional display a icon based on its content type.  If you can't determine the content type via CAML,  you could create a hidden column where each content type has a unique value, and the conditional check in CAML.  You could store the icons in a doc library on the site, and refer to them via relative path.

Anton wrote re: Custom Content Types with Custom Icons
on 12-02-2008 2:06 AM

Very interesting. Is it possible to change icons of *folder* content types? As I know, there are no document template parameter in advanced settings of such types...

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.