Click here to Skip to main content
15,886,780 members
Articles / Web Development / ASP.NET

Content Types - Part 1

Rate me:
Please Sign up or sign in to vote.
4.29/5 (4 votes)
15 Dec 2009CPOL8 min read 23.5K   14   1
Introduction about Content Types

Introduction

Content Types – The new term introduced in MOSS 2007. What are they? You would be familiar in filling out the properties whenever you work on a Microsoft Word Document. These properties would be similar to the ones displayed in the below diagram:

Image 1

The above diagram denotes properties that are displayed in a Microsoft Word 2007 document. These properties basically describe “about” the information present inside the Microsoft Word document that you have prepared. In other words, the Document Properties mentioned in Figure 1.0 describe the data mentioned in the Microsoft Word Document. This data is called Meta-Data.

MetaData

By now, you would have an idea as to what Meta-Data could mean. In the above section, I mentioned that the information displayed in the diagram in the above section describes “about” the data / information mentioned in the Microsoft Word document prepared by you. Meta-Data is data about data. In other words, Meta-Data describes information about the data that you have with you. The “columns” mentioned in Figure 1.0 appear in all Microsoft Word 2007 documents. These columns are the ones that are used for indexing and searching. That is, the information stored in these columns is used for searching whenever you search documents based on a key word.

Whenever you create a new Microsoft Word 2007 document, these columns appear by default. The same thing applies to other Microsoft Office 2007 documents like Microsoft Excel 2007, Microsoft PowerPoint 2007, etc. So, you can categorize the meta-data into Microsoft Word 2007 meta-data, Microsoft Excel 2007 meta-data, Microsoft PowerPoint 2007 meta-data etc. The objective is to basically categorize this meta-data for easy maintenance. Also in future, if you want to remove / add columns for only the Microsoft Word 2007 documents without affecting other Microsoft Office 2007 formats, the same can be done easily if you have a categorization.

Now, what if you had a scenario wherein you are developing a portal on MOSS 2007 for your client and you have to capture information that is common across departments. Apart from this, there might be additional information for each department that needs to be captured.

Let me share an example:

Imagine that for a Pharmaceutical Client called ABC, you are creating an intranet portal on MOSS 2007. The R and D department has various sub-departments, two of them being Ophthalmology and Neurology. The health experts for each of these respective departments prepare documents and record their findings in these documents. For this example, we can categorize these documents as Ophthalmology Documents and Neurology Documents. Now, the following can be the meta-data for both these document categorizations:

Common Properties

  • Name Of the Author
  • Subject
  • Title
  • Keywords
  • Department (Custom Column)

But in case there are additional columns which are unique for the Ophthalmology department and the Neurology department, what would you do? How will you handle this scenario? Enter Content Types.

What Is A Content Type

Based on the example mentioned in the above section, what if you have a provision to tag common properties to the documents loaded by the Ophthalmology Department and the Neurology Department and yet also provide a unique set of columns for both these departments depending on the type of document that they are uploading onto the portal. This is where Content Types come in handy.

Content Types are basically a collection of settings that you can relate / connect to a category of content (Ophthalmology Department of Neurology Department) or a type of content.

You can define a base content type at the Site Level of your MOSS 2007 portal and inherit the same in your sub-sites (Ophthalmology Sub Site and Neurology Sub-Site). While inheriting, you can add additional columns that you want for each specific requirement of each department.

By using content types, you can have better control on the meta-data of documents that you are uploading into the portal. The meta-data columns that we are talking about can be added into a Content Type in the form of “List Columns”.

Structure Of A Content Type

How is a content type organized? In the previous sections, I mentioned about terminologies like meta-data, list columns, content types, etc. Let us put all these things in place where they belong in order to understand the structure of a content type.

Figure_2.PNG

As you can see in Figure 2.0, the R and D Content Type contain meta-data (that is, information about documents created by the Ophthalmology department and the Neurology Department). This meta-data is defined by List Columns.

Now, where will these content types reside? The answer is, the content types reside in Content Type Groups. MOSS 2007 also provides you the option of creating your own Content Type Group and storing the content types created by you. The diagram given below depicts the same.

Figure_3.PNG

Also note that the Content Type Groups in-turn reside in the Content Type Gallery which is present at the Parent Site (Root Site Level) and also at the Sub-Site Level.

Content types which are created at the Root / Parent Site Level are known as “Global Content Types” (similar to the Parent Class / Master Class terminology used as a part of the Object Oriented Principles).

Content Types And Lists

We have been discussing about Global Content Types. Just to recall, a global content type is one which is created on the parent / root site and the same is available in all child-sites. Now, once these global content types are available in child sites, they can be added to a list. Now what happens is that you can also attach a content type to a list. When you add a content type (irrespective whether it is a global content type or a site content type) to a list, a copy of the same is done into the list. This in turn creates the List Content Type.

Figure_4..PNG

As mentioned in the above diagram, when you add a content type to a list, the columns mentioned in the content type is added automatically into the List which in turn creates the List Content Type. You can also add custom columns mentioned based on your requirement to the list. So, custom list columns and columns added through the content type co-exist inside the same list.

You can also have multiple content types added to the same list. The following is the depiction of the same.

Figure_5.PNG

Note that modifications made to the list content type reflects only inside that specific list.

Inheritance In Content Types

We know the concept of Parent Class and Child Classes which come as a part of Object Oriented concepts. We would have definitely come across scenarios wherein we would have added methods / functionalities that are common in parent classes and the same would be utilized in child classes which inherit the parent class. We also know that in the child classes, we can add additional set of methods / functionalities apart from the ones defined / inherited from the parent class.

Figure_6.PNG

In the above diagram, we can see that the R and D Content Type created at the Root Site / Parent Site can be inherited in the child sites / sub-sites – Ophthalmology Sub-Site and Neurology Sub-Site respectively. Once done, the same will look like below:

Figure_7.PNG

In the above diagram, we have three content types, viz, R and D Content Type, Ophthalmology Content Type and the Neurology Content Type. The R and D content type contains columns / meta-data that is common for both the Ophthalmology / Neurology content types respectively. Whereas both Ophthalmology / Neurology content types have columns / meta-data which are common to both as well columns which are unique. This becomes possible as both the Ophthalmology / Neurology sub-sites are the child sites of the Root / Parent Site. Not only does the Ophthalmology / Neurology content types inherit the “properties” of the R and D content type, they also modify the R and D content type by adding their department specific “properties”.

Change Control Management on Content Types

You can make content types that you create as either of the following:

  • Read-Only Content Types

    In case you do not want anybody to change the content type that you have created, then set the content type as read-only. By doing this, if in case a user tries to modify the content type marked as read-only, then the user would get a warning message stating that the content type is read-only. However, the same can be changed if the users manually set the read-only option to “False” if they have rights / permissions to do so.

    If a content type created at a root site level is marked as read-only, then there will be complications that would arise while trying to push modifications made to this content type if the same is inherited by content types present in child-sites.

  • Sealed Content Types

    In order to prevent from the complications of marking a global content type as read-only, if you do not want modifications made on a content type not to be pushed onto its “child content types”, then mark that specific content type as sealed.

    In order to set a content type as sealed, you need to have site collection administrator rights. You need to have the same rights in order to unseal a sealed content type.

Default / Out-Of-The-Box Content Types of MOSS 2007

MOSS 2007 comes with default out-of-the-box content types which are as follows:

Figure_8_1.PNG

Figure_8_2.PNG

Ways of creating Content Types

Content Types can be created in the following ways:

  • Creation through MOSS 2007 user interface
  • Creation by using the SharePoint Object Model
  • Creation as a part of the Feature deployment in existing sites or in new sites

Conclusion

In this article, we have seen the overview of Content Types. In my next article, we will see the next set of advanced features of content types and also how content types can be extended in order to add workflows.

History

  • 15th December, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralTitle is a bit confused Pin
Sohel_Rana18-Dec-09 21:10
Sohel_Rana18-Dec-09 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.