2

My customer want to have a global taxonomy for all content. I have created content types that inherit from the usual content types (Documents, Pictures, Pages) that will contain this taxonomy.

To keep the contributors of the sites from creating rogue document libraries, pages libraries and picture libraries that does not have the custom content type, I want both the list i provision using my custom web templates, and the lists created by users afterwards to use my content types rather than the OOB ones.

My suggestion is to use the SPListEventReceiver.ListAdded that we have now in SP2010, possibly setting SPEventReceiverSynchronization to Synchronous.

I'm pondering if this is the best way of achieving this, and wanted some input on better ways of doing this, caveats etc. Any input appreciated.

2
  • 2
    Can't you just move the content types you don't want available into the "_Hidden" group?
    – SPDoctor
    Commented Apr 26, 2011 at 8:30
  • I like the idea, and might combine that with the above... What happens if you only hide the OOB site CT's like Document? I guess the user will still be able to create a doclib (cant see why not) Commented Apr 26, 2011 at 13:24

2 Answers 2

1

I don't see a problem with your suggested approach. In fact, it was the first idea that came to my mind as well.

How are you going to stop users from using the library settings to change the default back to OOTB CT's? You might want to add an event receiver that cancels document adding operations if content type requirements are not met, just as an extra precaution.

2
  • Other options to consider was to edit the OOB list definitions by code instead of waiting for the user to instantiate... Pros/cons.. hmm Commented Apr 26, 2011 at 13:23
  • having second thoughts with the list template idea (mainly SLA issues that might occur) so i think im back with my original idea! Thanx for your comments Commented Apr 29, 2011 at 13:12
1

I had this exact request from a client. I created an "unstapler" feature. It was simply a feature receiver that deactivated features from a semicolon delimited list of GUIDs. So while I had one feature to activate my custom list definitions, I used this feature to deactivate the OOTB list definitions that I wanted to replace:

<FeatureSiteTemplateAssociation Id="EAD66289-5E7E-45D5-8B93-56AC416DCB0F" TemplateName="BLANKINTERNET#0">
    <Property Key="FeatureIds" Value="00bfea71-e717-4e80-aa17-d0c71b360101;00bfea71-52d4-45b3-b544-b1c71b620109;00bfea71-ec85-4903-972d-ebe475780106" />
</FeatureSiteTemplateAssociation>

The second part was changing the master page so that Site Actions > New Document Library would point to the custom list definition instead of the OOTB document library:

<SharePoint:MenuItemTemplate runat="server" id="MenuItem_CreateDocLib"
    Text="<%$Resources:wss,siteactions_createdoclib%>"
    Description="<%$Resources:wss,siteactions_createdoclibdesc%>"
    ImageUrl="/_layouts/images/NewDocLibHH.png"
    MenuGroupId="200"
    Sequence="220"
    UseShortId="true"
    ClientOnClickScriptContainingPrefixedUrl="if (LaunchCreateHandler('DocLib')) { GoToPage('~site/_layouts/new.aspx?FeatureId={00bfea71-e717-4e80-aa17-d0c71b360101}&amp;ListTemplate=101') }"
    PermissionsString="ManageLists"
    PermissionMode="Any"
    VisibilityFeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" />

I changed ClientOnClickScriptContainingPrefixedUrl to:

GoToPage('~site/_layouts/new.aspx?FeatureId={9C982E22-33F4-4A0A-82F9-19596A9045D0}&amp;ListTemplate=100316')

and VisibilityFeatureId to:

9C982E22-33F4-4A0A-82F9-19596A9045D0
4
  • i like the fact that it goes to the root of the problem, eg the list definitions instead of instantiation time. I would probably prefer a solution where i edit OOB list defs instead of replacing with custom. Also i cant use feature stapling though since i am using custom web templates, but I could incorporate it in my onet. Was this done for SP2010 or 2007? Commented Apr 26, 2011 at 13:22
  • This was SP2010. I would have preferred custom web templates, but the web application was hosted by SP Online, so it wasn't an option. I had to use stapling. My "unstapler" isn't true feature stapling, so, as you were saying, you could easily add a similar feature into the SiteFeatures section of your onet. Commented Apr 26, 2011 at 14:41
  • Hmm weird because custom web templates are exactly made for SP Online, since solutions are uploaded to a sites content db, not 14-hive? Commented Apr 26, 2011 at 18:05
  • Sorry, mixing up my terms. Custom site definitions are not allowed, custom site templates are. Commented Apr 26, 2011 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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