次の方法で共有


How to hide the new menu folder option from document library by default to all the document library instances

One of our customer came with a requirement of hiding the new menu folder option from the document library instances by default.

This can be done through UI as well but customer don't want to do this manually through UI. By default folder creation is enabled in UI.

The New folder button appears because of "Folder" Content type (0X0120) associated with the document library definition and as well the "FolderCreation" attribute is set to TRUE by default in the document library definition.

If we create a new custom document library definition and set the "FolderCreation" attribute to False in the schema for the "List" element then we can hide the "New Folder" creation in the document libraries. Create a custom document library definition by copying the OOB document library definition and set the "FolderCreation" attribute to False in the schema for the "List" element. This will completely hide the New Folder option under New menu and as well you can check in the UI that "Folder" creation is set to "No" by default.

 

<?xml version="1.0" encoding="utf-8"?>

<List xmlns:ows="Microsoft SharePoint" Title="$Resources:shareddocuments_Title;" Direction="$Resources:Direction;" Url="Shared Documents" BaseType="1" FolderCreation=”False”>

  <MetaData>

    <ContentTypes>

      <ContentTypeRef ID="0x0101">

        <Folder TargetName="Forms/Document" />

      </ContentTypeRef>

      <ContentTypeRef ID="0x0120" />

    </ContentTypes

      .

      .

      .

Install and activate the custom document library definition and create a new document library instance from the custom document library definition. Now you can find that the document library instances created from the custom document library definition are not having the “New Folder” option under the New menu in the toolbar. If you browse to the document library setting you can find that the folder creation option is set to false by default and if required you can enable it by changing the settings.

Note : Don't remove the folder content type from the document library definition or don't set the "FolderCreation" attribute in the "ListTemplate" element in the element manifest. Because it completely removes the folder creation and folder content type from the doc lib definition which can cause some problem in future. Its always better to override this property directly in the schema rather than in the definition so that we can keep the folder feature and just hide it.

Comments

  • Anonymous
    January 27, 2010
    Hi Syed, I'm doing something similar, in that I've got my own custom default Document Content Type and custom default Folder Content Type, both of which inherit from the original built-in types. I've removed the built-in Document Content Type and I've removed "New Folder" using the standard manual config method (I'll eventually package this up for automated deployment later), which works great if the user is working with the standard menus. But if a user switches to the Explorer View (or Open with Explorer) and then drag'n'drops (or copy/cut&paste) any folders pick up the built-in Folder Content Type rather than my custom one. Documents are fine, they pick up my custom document content type. Any ideas on how to remove the built-in folder content type and what issues I'll run into if I do? Thanks Craig