Stumbling Through

Join me as I stumble, bumble and fumble my way through some new developer technologies. We'll laugh, we'll cry, there may be a mouse tossed through a monitor, but in the end we will all hopefully learn something.
in

Stumbling Through: SharePoint 2007 (Content Types - Part II)

We left off last time with a definition of a 'base class' of sorts, our 'Asset' content type.  I call it a base class because it contains the properties (columns) that are common to all assets, that and we will never create an 'Asset', rather we will be creating Laptops, Monitors and Hard Drives.  Lets get started with that right now by creating our 'Hard Drive' content type.  As before, click 'Site Actions' and then 'Site Settings', then 'Site Content Types' from the menu that appears.  Click 'Create' and name the new content type 'Hard Drive'.  This time, when it asks us for the 'Parent content type', we can select our 'Clarity Assets Content Type' group to filter down to our 'Asset' content type to derive from.  This will automatically get us all the columns from the 'Asset' content type.  We will specify to add this content type to our 'Clarity Assets Content Type' group (yeah yeah, I spelled it wrong, so what?):

image

After we click ok, we can see the columns associated with the content type.  Title is there because that is Asset's parent content type, and the rest are there because we are deriving from Asset; all of this is easy to see in the 'Source' column.  Add the 'Capacity' column similarly to how we added all of the other columns:

image

Let's follow the same process to add 'Monitors' with their 'Screen Size' column and 'Laptops' without any special columns.  Your content types site gallery should look like this:

image

And your site columns gallery should look like this:

image

Now we need to create a list that will consume these content types.  Go to 'Site Actions' - 'Create':

image

Select 'Custom List' from the create menu:

image

Name the list 'Clarity Assets', and for ease of use, make it available from the quick launch menu:

image

Ok, great.  We have our list, but it doesn't seem to have anything to do with assets... how do we hook it in to our content types?  Good think I stumbled through this already so I can walk you through it.  On the Clarity Assets list, click 'Settings' and then 'List Settings':

image

In the 'Customize Clarity Assets' screen, select 'Advanced Settings':

image

Well well, looks like the very first option here deals with content types... 'Allow management of content types?' it asks?  YES!

image

After clicking ok, we are brought back to the 'Customize Clarity Assets' screen, only this time there is a section for 'Content Types':

image

By default, the list manages 'Items'.  This is all well and good, but we want it to manage our various asset content types.  Note, however, that we do NOT want to have it manage our base Asset content type... allowing it to do so would allow the user to add 'Assets', which wouldn't really mean anything in a business sense.  Use the 'Add from existing site content types' link to add our three content types:  Laptop, Monitor and Hard Drive.  Our 'Clarity Asset Content Types' grouping comes in real handy here, as selecting it limits our options to only our stuff:

image

Click ok and we can see that the list will now manage these asset types, which means that they will be available from the 'Add' menu and editing them will take advantage of the columns assigned to them.  We still have 'Item' associated with this list though, and it wouldn't make sense to allow the user to add an 'Item', so lets remove that.  Click it and say 'Delete this content type':

image

That sounds scary, like it is going to delete our base class, but it only removes its association from this list.  Now we are good to go, get back to the list itself (click 'Home' and then 'Clarity Assets').  Still looks the same to me, but now if you click the 'New' dropdown, you'll see the option to add only the content types that we defined:

image

Not only that, but if we actually select one of those items, say, 'New Hard Drive', we are presented with a data entry screen specific to the columns of a Hard Drive (per our content type definition):

image

Cancel that add, there is one other thing we need to do to make our list somewhat complete.  By default, it is showing only the 'Title' of all our assets.  No matter what type of asset it is, we know that it will have Title, Manufacturer, Model and Serial Number so why don't we always display those columns by default?  To do so, click the dropdown next to the 'All Items' view and select 'Modify this view':

image

Among other things, we can specify the columns to display in this view.  It retrieves all the possible columns based on the content types associated with this list, so we have the option to select 'Capacity' or 'Screen Size', but we shouldn't because not every item in the list will have values for those.  We would create special views for 'Hard Drives' and 'Monitors' to account for that.  For now, just select the columns we know every asset will have:

image

Now our list is looking a little more informative:

image

As I said earlier, lets create a custom view for each of our content types, including the columns that are specific to them.  You can do this by clicking the dropdown next to 'All Item's and selecting 'Create View':

image

Select 'All Items' to base this view on that one, it will give us all the default columns:

image

Name the view and add the columns you want, in this case I named the view 'All Hard Drives' and selected 'Capacity' in addition to the columns already selected.  Now we need to tell it to only show records with a content type of 'Hard Drive'.  This functionality can be achieved via the 'Filter' property.  Specify it as follows to achieve our desired results:

image

Click 'Ok' to save, and repeat the process for a 'All Monitors' and 'All Laptops' view.  When you are done, start adding some records of various types and use the new views to see how they work.

Leave a Comment

(required) 

(required) 

(optional)

(required)