Monday, July 16, 2012

SharePoint 2010: No Site Content Types Link

One of the most discuraging issues you will find when working with Content Types in SharePoint is a very simple issue. The Site Content Types link in the breadcrumb is not a link at all. Instead it is some grayed out text that irritates you every time you try an click on it.

So I got tired of trying to do this and thought I would take matters into my own hands.

Here is what I came up with:
function AddContentTypeLink() { 
   var spans = document.getElementsByTagName('h2'); 
   var stringToMatch = ' Site Content Types '; 
   for (var i = 0; i < spans.length; ++i) { 
     if (spans[i].innerHTML.indexOf(stringToMatch) != -1) { 
       spans[i].innerHTML = spans[i].innerHTML.replace(stringToMatch ,"<a href='/_layouts/mngctype.aspx'>" + stringToMatch + "</a>"); 
       break;
     }
   }
 }
 _spBodyOnLoadFunctionNames.push('AddContentTypeLink');

Add this to an existing JavaScript file you have on the go (or in a CEWP on the settings pages where it exists if you are desperate)

If all worked properly you should be left with this:

It may not be pretty but it works well...

If you are working in a different language you can change the string variable to whatever it translates to (French for example is " Types de contenu de site " (don't forget the leading and trailing space!)

No comments:

Post a Comment