PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Custom Content Type without Title Field

Posted by PANVEGA on January 14, 2009

In my previous post https://panvega.wordpress.com/2009/01/14/how-to-create-a-custom-content-type-with-a-feature I explained how to build a Custom Content Type.

In this post I wanna show how to remove the default Title field with it´s Item Content Type from your Custom Content Type. By default you can not delete this special kind of field from your list. In addition sometimes it is annoying having this irritating default field.

Example:

<FieldRefs>

<FieldRef ID=”{6B7EB650-9ABB-4f6d-959A-BC30EF507067}”

Name=”StudentID”/>

<FieldRef ID=”{3EB9CAF3-C9D6-4857-A297-7D2983A0B5C5}”

Name=”FName”/>

<FieldRef ID=”{44D3AA0F-B35F-4c7d-94F4-88824823D284}”

Name=”LastName”/>

<FieldRef ID=”{038D1503-4629-40f6-ADAF-B47D1AB2D4FE}”

Name=”Company”/>

<FieldRef ID=”{963AE87B-4FE3-467f-91C3-7C878CC4BFF7}”

Name=”Email”/>

<FieldRef ID=”{fc2e188e-ba91-48c9-9dd3-16431afddd50}”

Name=”WorkAddress”/>

<FieldRef ID=”{0E6A0F76-DD45-4ea9-926D-D0A90CED5BA4}”

Name=”PostalCode”/>

<FieldRef ID=”{6ca7bd7f-b490-402e-af1b-2813cf087b1e}”

Name=”WorkCity”/>

<FieldRef ID=”{8CD101C6-0667-48cf-97E4-B0DE9E7873E5}”

Name=”Country”/>

<FieldRef ID=”{32045CEE-D805-4031-A9E2-87A227CABD7E}”

Name=”Telephone”/>

<FieldRef ID=”{F6CC5286-FF3F-412e-BA42-0691A560EC67}”

Name=”Remarks”/>

</FieldRefs>

After deploying my site columns feature and content type feature, I created a content type enabled list based on my own content type. I also removed the base content type, which is Item.

When I wanted to add an item to my Students list I saw that the Title field was still there, even if I hadn’t defined it in my content type.

students1

The explanation for this is that I derived my content type from the Item content type, which has the Title field included. When I was making my list depending on my content type I could already have seen it in the Settings page:

students3

Clearly, after removing the Item content type, the Title is still there because it is also part of the Students content type.

If you don’t want certain fields of your base content type (in my case it is Title) to appear in your own content type, you need to add an extra element to your content type definition, namely the <RemoveFieldRef> element.

My content type now looks like this:

<FieldRefs>

<RemoveFieldRef ID=”{fa564e0f-0c70-4ab9-b863-0177e6ddd247}”

Name =”Title”/>

<FieldRef ID=”{6B7EB650-9ABB-4f6d-959A-BC30EF507067}”

Name=”StudentID”/>

<FieldRef ID=”{3EB9CAF3-C9D6-4857-A297-7D2983A0B5C5}”

Name=”FName”/>

<FieldRef ID=”{44D3AA0F-B35F-4c7d-94F4-88824823D284}”

Name=”LastName”/>

<FieldRef ID=”{038D1503-4629-40f6-ADAF-B47D1AB2D4FE}”

Name=”Company”/>

<FieldRef ID=”{963AE87B-4FE3-467f-91C3-7C878CC4BFF7}”

Name=”Email”/>

<FieldRef ID=”{fc2e188e-ba91-48c9-9dd3-16431afddd50}”

Name=”WorkAddress”/>

<FieldRef ID=”{0E6A0F76-DD45-4ea9-926D-D0A90CED5BA4}”

Name=”PostalCode”/>

<FieldRef ID=”{6ca7bd7f-b490-402e-af1b-2813cf087b1e}”

Name=”WorkCity”/>

<FieldRef ID=”{8CD101C6-0667-48cf-97E4-B0DE9E7873E5}”

Name=”Country”/>

<FieldRef ID=”{32045CEE-D805-4031-A9E2-87A227CABD7E}”

Name=”Telephone”/>

<FieldRef ID=”{F6CC5286-FF3F-412e-BA42-0691A560EC67}”

Name=”Remarks”/>

</FieldRefs>

Clearly, when now making my list depending on my content type, I can already notice that Title is  only part of the Item content type.

students2

I hope that helps!

Advertisements

One Response to “Custom Content Type without Title Field”

  1. CWFoote said

    Another way to approach this is to use the GUID of the “Title” field in your Content Type definition, but change the DisplayName to something more meaningful. This preserves the built-in (and very useful) view options you get with Title, such as “Title linked to Item”, “Title linked to Item with Menu”, etc.

    In the example above, you would use “StudentID” as the DisplayName value for the Title GUID, rather than creating a new StudentID field, and removing the Title field. Then you can click on StudentID in a view, and see the Edit form or Display form.

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: