23 Juni 2008

Update Content Type with a Feature

If you deploy your Content Types with a Feature, you will run into a problem, when you would like to modify the Content Type. If you modify and redeploy the Feature, then the Site Content Type is disconnected from the List Content Type. This is because very time a Content Type is assigned to a list, a new List Content Type is created, which inherits from the Site Content Type.

If you do the modification manually you should always modify the Site Content Type. While doing via Site Settings, you have an option which force SharePoint to propagate the modification to all the List Content Types inherited from the Site Content Type.

But when you do the modification by changing the Feature, then SharePoint won't update the inherited List Content Types. There are some STSADM extensions which do this work for you (i.e. from Gary Lapointe or Søren Nielsen).

I took the Code from Søren Nielsen and put it in a FeatureActivated Event Handler. In my Content Type Feature.xml I set the ReceiverAssembly and ReceiverClass attribute. This allows you the modify the Content Type in the Feature, upgrade the WSP, deactive and finally reactive the Feature. Reactivating the Feature will change the Site Content Type. SharePoint will propagate the modification with the FeatureActivated Event Handler to all the List Content Types inherited from the Site Content Type.

If you just add some Site Columns to your Site Content Type (or delete some unused Columns), this would make your deployment and change management process much more easier. Perhaps almost as easy as the good old ALTER TABLE SQL scripts ;)

Here is the my Code. Just copy the ProcessWeb() and all the other method from Søren Nielsen's blog.

03 Juni 2008

Object Required Error – Drag & Drop of Web Parts

Some days ago one of my MOSS 2007 WCM sites faced up with an "Object Required" Java Script error while a content editor tried to drag & drop a Web Part in a custom Web Part Zone. Usually this sets the index of the Web Part in this Zone.

All right.. I tried to debug the problem with Visual Studio. The Debugger gave me the information about a missing offset in function “MSOLayout_GetRealOffset”, but I wasn't able to figure out what the reason for this behavior could be. After the provisioning of a new Site with the Standard Master Pages and Style Sheets applied, the error didn’t appear anymore. This means that it had something to do with my custom Styles I applied.

Step by step I reapplied my CSS and discovered that the error only appears when I apply the custom styles for my WebPart Zone Holder Divs.

In my CSS I had defined the property: “position: relative”, which caused the error.



You should use no other position definitions than “position: static”. This is the only way it works.



Drag & Drop anyway just works in Internet Explorer, but to miss this functionality is indeed not user friendly.