I have a small Visual Studio 2010 project with one farm level feature that I deploy to a site collection which is configured as my content type hub. The FeatureActivated event adds a site column and then adds a custom content type made up of the newly added site column and a few other existing site columns.
There are several other site collections in this web application and they are all eventually getting the content type published to them from the hub. That part works OK.
What is the best method of UN-publishing a content type from a site collection that was a target of the hub? I cannot find any info on this.
When I deactivate the feature in the hub site collection, it removes things properly but the other site collections that received these items via syndication with the hub continue to have the site column and content type (despite removal from the hub).
Here is a snippet of my feature
public class TeleWorkAgreementEventReceiver : SPFeatureReceiver
{
private const string ContentTypeName = "Tele-Work Agreement";
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
//Get references to the site and web, ensuring correct disposal
using (SPSite site = (SPSite)properties.Feature.Parent)
{
using (SPWeb web = site.RootWeb)
{
var ct = web.ContentTypes[ContentTypeName];
if (ct != null)
{
ct.Delete();
DeleteField(web, "ApprovingOffical");
}
}
}
}
In short, if content type publishing pushes things from the hub to the "spokes", what is the best way to remove things later. My thought is that if I add XXXX to the hub and XXXX gets published to other site collections, then deleting XXXX from the hub ought to withdraw XXXX from the other site collections (but I'm pretty sure things don't work that way).