How to create content types in sharepoint 201009.11.2020
Creating Content Types
Create a content type. In the Navigation pane, click Content Types. On the Content Types tab, in the New group, click Content Type. The Create a Content Type dialog box opens. Type a name for the list in the Name field. Type a description for the list in the Description field. In the Select parent. On the File menu, point to New, and then click Project. In the New Project dialog window, in the Installed Templates section, click Visual C#, click SharePoint, and then click Select Empty SharePoint Project from the project items. In the Name box, type CreateContentType and then click OK.
As a iin, you create a content type by writing declarative XML or perhaps server code. This is cnotent something that you do as typee of creating a Feature that someone what is the oxidation state of mn in mno4 installs and still another person activates. Therefore, what you are really doing to a content type is not creating it but defining it. Eventually, the Feature is installed and someone activates it.
Microsoft SharePoint Foundation executes your code or reads your declarative XML and makes the content type available. An administrative user who has permission to manage lists applies the new content type to a list or document library, and it is in play. Any user who is allowed to add items to the list can use your content type to create content.
Administrative users can what can be found in urine culture the content type to suit themselves by adding or removing columns, or changing other attributes. All of that is out of your hands. The key point, then, is that "creating" a content type really means creating a content type definition. A good content type definition anticipates how the content sharepointt is ultimately used.
You never create a content type from scratch. Instead, you always select an existing content type as the basis for any new content type fontent you create.
This is exactly what Microsoft SharePoint Foundation does for its built-in content types. The website where a new content type is created must be in scope for the content type from which it is derived, so you go consider this when you write your content type definition.
For more information, see Content Type Scope. SharePoint Foundation supports a limited form of content type inheritance. When the Feature that defines a new content type is activated, columns and other metadata that are defined sharepiint the parent content type are passed on to the child content type. This is the only part of inheritance that is automatic. In earlier versions of SharePoint Foundation, columns and metadata that were added to a content type after it was provisioned were not inherited by child content types.
In SharePoint Foundationthis behavior has changed. You now sharepoinr the option to include columns and metadata that users have added to the parent. Ij more information, see the description of the Inherits attribute on the ContentType element. After a content type is made available and is being used, you or someone else can modify the definition for the parent content type, but that change is not automatically pushed down to derived content types.
This aspect of inheritance must be initiated manually, either through the user interface or in custom code. For more information, see Updating Child Content Types. However, content tyes inheritance does allow you to work with content types much as you would with derived bow. For example, just as you can override properties of a base class, you can modify attributes that your content type derives from its parent content type. You can add, alter, or hpw columns; specify different NewEditor Display forms; specify a different document template; and so on.
What was i supposed to do this means, then, is that you can create base content types just as you create base classes in developing an application framework. For example, you could define a content type named Financial Document with characteristics common to all financial documents in your organization.
You could then use Financial Document as the basis for new content types, such as Invoice and Purchase Rceate. The new content types inherit columns and other metadata from Financial Document, so you define common elements only once, on the parent content type. You can get ideas for building your own content type hierarchy by studying how SharePoint Foundation uses inherited attributes of base content types, and how it modifies them.
A good place to start is with the content type gallery in the user interface. On the Site Cfeate menu, select Site Settings. On the Site Settings page, under Galleriesclick Site content types. On the Site Content Types page, click the link for an interesting content type. Another good resource for study is the file ctypewss. This file contains the definitions how to start an f1 team many of the built-in content types.
For help in understanding the definitions see Content Type Definitions. For a comprehensive guide to planning content types, see Planning content types and workflows.
The following are some general considerations:. Where in the site hierarchy do you want the content type to become available? If the content type should be available throughout an entire site collection, you should deploy it in a Feature with site collection scope and write code in the FeatureActivated method of a feature receiver class that adds the content type to the root website's content zharepoint collection.
Which existing content type that is in scope will you choose to derive your content type from? Your cintent type will not activate correctly if the parent content type is not available in the website where your content type is created.
Columns that are not inherited from the parent content type must be added. Columns that do not hos must be created. Other Resources. Will the content type require language resources? Document templates? If the content type requires any of these resources, you must know how they will be provisioned and how the content type will access 22010. One way to create a content type is to use declarative XML to define the content type in the element manifest file for a Feature.
When the Feature is activated, the content type is created. You can define several content types in the same element manifest file. Include a ContentType element sgarepoint each content type that you define. The ID attribute is required, and the value that you specify must follow a very specific format.
A correctly formatted content type ID identifies not only the new content type but also its parent content type. For more information, see Content Type IDs. To create an ID for a content type that is derived from a built-in content type, start with the hexadecimal string that identifies the built-in content eharepoint, append two zeros, and then add a GUID with all the punctuation removed.
For example, the hexadecimal string tgpes identifies the Item content type is "0x01". The ID for a content type that derives from Item should look something like the following:. To create IDs for additional content types that inherit from your content type, append "01", "02", and so on. Another required attribute of the ContentType element is Name, which specifies a display name. For more information, see Localizing SharePoint Solutions.
When you include columns in a content type, you do not create them in the content type definition. Instead, you reference columns that have been created elsewhere. To include a column cintent, add contenh FieldRef element what to wear on fashion show a child of the ContentType element. The referenced column can be one that already exists as a site column or a sharrpoint column created by the same Feature that creates the content type.
For information about creating site columns, see Field Definitions. You can also use the FieldRef element to reference a column that the content type inherits from its parent content type. In this case, your reason for referencing the column would not be add the column but to change some of its characteristics when it is used in the content type.
The ID attribute of the FieldRef how to create content types in sharepoint 2010 identifies the column that you are referencing. The value should be the string representation of a GUID, including braces. The value is case-sensitive. You can find the IDs for built-in fields in the file fieldswss. If your content type uses a document template for new content, you can identify it in a DocumentTemplate element within the ContentType element.
You must provision the file separately. One way to do that would be to add a Module element to the manifest and include the file with the Creaye. For more information, see How to: Provision a File. The content type definition can also include definitions for custom forms through an XMLDocuments element. For more information, see Custom Information in Content Types. The following example shows the element manifest for a Feature that creates four site columns and three site content types.
The first content type, Financial Document, is a child of the built-in Document content type. The remaining two new content types, Invoice and Purchase Order, both derive from Financial Document. The FieldRef element that references the DateOpened column sets the DisplayName attribute so that the column name will render as "Date" instead of "Date Opened" as defined in the site column.
The Invoice content type is the first of two new content types that derive from Financial Document. The definition for the content type references a third new site column, Client, and sets conteny Required attribute to TRUE so that an creatf is typse for this field when a new item is created. The Invoice type includes a FieldRef element for the Title column, even though it hw inherited, in order to change the value of the DisplayName attribute from "Title" to "Service".
Ot second how to create content types in sharepoint 2010 type that derives from Financial Document is Purchase Order. The definition for the content type references a fourth new site column, CostCenter, and sets the DisplayName attribute so that the column name will render as "Department" instead of "Cost Center" as it is defined in the site column.
Purchase Order inherits the column references from its parent, Financial Document, so you do not have to reference them again. What is gattaca one world com content type also inherits a reference to the Title column from Financial Document, which inherits the column contejt its parent, Document.
The Purchase Order type includes a FieldRef element for crete Title column in order to override the inherited DisplayName attribute with a value of its own. As an alternative to using declarative XML to create a content type, you crete use the SharePoint Foundation object model.
Typically, declarative XML is easier to write. However, declarative XML generally offers less flexibility than the object model, which has access to the capabilities of the entire Microsoft. NET Framework and can be debugged at sharepount time.
Content Type Inheritance
To create the list. Start Internet Explorer and browse to the Web site where you have created the new content type. In the upper-left corner of the page, click Site Actions and then click More Options. Click List in the Filter By menu in the Create dialog screen. Select Custom List. Type New.
Creating a new Content Type project in Visual Studio Editing the content type details. Adding a new field to the XML markup.
Including a reference to the new field from within the content type element. You will create a content type definition named Official Documents that is based on the Document content type. Then, you will add a choice column for Review Status , and deploy and use this content type. Aspired to become a SharePoint? Explore the post to discover the know-how on the " SharePoint Training " course.
On the File menu, click New , and then click Project. In the template page, click Content-Type. In the Name box, type Official Documents. Leave other fields with their default values, and then click OK. In what local site do you want to use for debugging?
Select the Deploy as a farm solution Then, click Next. In the Choose Content Type Settings dialog box, in the Which base content type should this content type inherit from? Click Finish. To edit the content type details in the Elements. The markup should look similar to the following. To add a field to the Elements. Notice that this includes a new field that will be identified with a new GUID.
In the General Settings section, click Advanced Settings. At the bottom of the form, click OK. On the List Information page, in the Content Types section, click Add from existing site content types.
In the Select site content types from the drop-down list, click Custom Content Types. Then, click OK.
On the List Information page, in the Content Types section, click Change new button order and default content type. Clear the Visible checkbox for the Document content type, and then click OK. In the list of items, click Add document. Browse to a document, click Open to upload it, and then click OK. In the dialog box, note the Review Status drop-down list that is associated with the Official Document Content-type. Save the document. This Visual How To walks you through the following: A content type is created by using a wizard in Visual Studio The Field Type is set to Choice , and then the choice options are added.
This ensures the field is included in this content type. For an in-depth understanding of SharePoint click on:. To deploy the project In Solution Explorer , right-click the project and then click Deploy.