Adding a Content Type to a Hub Using a Feature
The more I work with content types , the more I like to do everything programmatically rather than declaratively using features. Here is a funny thing that may make you scratch your head for a while:
- Create a feature that adds a content type to a content type hub.
- Publish the content type in the hub.
- Let the publishing/subscribe timer jobs run (every hour or so) or manually execute them through Central Admin site.
- In a subscribe site collection, check the content type publishing error log.
It errors out saying that you need to install the feature on the subscriber site collection. Although, you don’t need to activate the feature on the target subscriber , I still think the dependency on feature installation on the subscriber site collection is somehow odd!
Whether this is by design or just a bug , I don’t know, but here is the resolution :
Resolution: Add the content type to the hub either through the browser, PowerShell or use a console application for what that matters!Using features to add content types is really not worth the headache.
hello Reza, I added my content types declarativly on the site collection and activated the content type syndication hub manually, but how to i publish the content types programmatically as they are a lot of content types?
You would use ContentTypePublisher.Publisher(SPcontentType)
Example: http://msdn.microsoft.com/en-us/library/ff394469.aspx