Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

Deleting content types from the hub orphans them in the spokes.

The technique I use is to delete the content types from the spokes first (you'll have to set ReadOnly = false before deleting) then un-publish the content type in the hub and then delete the content type from the hub.

share|improve this answer
    
Thanks. Do you delete the content type from the "spoke(s)" manually with the browser, with a Powershell script, or some other way? I was kind of hoping for a re-runnable farm-level feature that upon deactivation did NOT leave orphaned content. –  John Adams Jul 31 '12 at 22:14
    
is there anything you can do about orphaned content types on spokes? like for instance if the content type hub gets deleted? –  Nacht Mar 6 at 4:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.