in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

tchmiel's blog

Tom's SharePoint Findings

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   

Comments

 

Links (8/26/2007) « Steve Pietrek’s SharePoint Stuff said:

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

August 26, 2007 6:46 PM
 

15 Links Today (2007-08-27) said:

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

August 27, 2007 10:20 AM
 

EddieV said:

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

November 28, 2007 9:01 AM
 

tchmiel said:

@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?

November 29, 2007 5:35 PM
 

Casey Hanks said:

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

March 27, 2008 8:09 AM
 

tchmiel said:

@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.  

March 27, 2008 8:44 AM
 

tchmiel said:

@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.

June 4, 2008 3:59 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts