Sharepoint Content Types (1)

If we create a content type called Trip Report we could also create a Word document template and associate it with the content type TripReport.

All content types in SharePoint are organized in a hierarchy. Each content type in SharePoint inherits its attributes and settings from a parent content type. This means that every time we want to create a new content type we must choose an existing parent content type.

There are site collection level, site level and list level content types.

The content type Dublin Core Columns
are used to describe resources online, such as text, video, sound, images, and web pages. The metadata was defined that was held in Dublin, Ohio.

Develop new content type in VS 2010

In VS 2010, new project, select Content Type as template, name: MyFirstContentType, farm solution. In the next screen, select Picture as the inherit content type.

Open Elements.XML. The new content type is inherited from Picture, but we want to remove 3 columns from this new content type: (1) Date Picture Taken, (2) Picture Size and Keyword.

So in the Elements.xml file, make edit:

The ID of the two columns, do this to get them: In Server Explorer, explorer to Sharepoint web site, click Content Types, look for the context type (Picture), and then expand fields. Look for the ID in the properties pane.

Then we have to remove Inherit=”TRUE”
from Elements.xml. If we don’t , it will still inherit all fields from Picture.

Let’s add a new Site column: “City”. It works too.

Now let’s create a new doc library and assign this new content type to it. Click Library.

Click Create button. Select Library Picture Library. Name is My Photo. Create it.

Go to the My Photos library, to change library settings, click Picture Library Setting.

Advanced Setting

Allow Content Management set to Yes, so we can associate new content type.

Go back to Library setting page, you see the option to add new content type. Add our custom content type, and delete the default one (Picture) if you want to.

 
 

Try to add a new picture, and see if the new content type works:

You always get this File-upload only dialog box; once you select a file and click OK, you will be asked other info, including the City.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: