Content parts vs content types

Nov 17, 2010 at 11:22 AM

I thought I understood this, but now I'm not sure. So, what is the dfference between a content part and a content type?

Nov 17, 2010 at 12:10 PM

A content type can contain multiple content parts, but only one of each content part definition (eg. a blogpost can contain one comments content part and one body part).

Nov 17, 2010 at 5:50 PM

I think if you are a programmer, then you can view a content type as being an aggregate class definition.

Coordinator
Nov 17, 2010 at 6:28 PM

An explanation can be found here: http://orchardproject.net/docs/How-Orchard-works.ashx#Types_Parts_and_Fields_0

Nov 19, 2010 at 5:28 PM

Think I've got my head round it now. Thanks for the help and links.

Some documentation on working with data would be really useful. Unless there is some that I've missed. When should you rely on the handlers to do it for you automatically and how can you do it yourself using the ContentManager. Been struggling with this the last few days, but think I'm almost getting there.

Nov 20, 2010 at 8:30 PM

The doc says: "fields on a part are a dictionary of strings to values of the field's type, whereas the content type is a list of part types"

So what is the structure when a content type has a field? Will the field be wrapped in a part to attach to a content type?

Also, can a field have more than one value? For example a name and a url, each validated separately?

 

Coordinator
Nov 20, 2010 at 10:54 PM

Yes, a field is attached to a part technically.

And yes, you can have multiple values. That's why the Storage propoerty is indexed by name. The default text field has only one value, and the index is null. Internally it save the content to the innerText of an xml node. You can also define settings to customize the behavior of the value. Take a look at DateTimeField and TaxonomyField (in the taxonomy module) for more examples.

Nov 22, 2010 at 12:43 AM
Edited Nov 22, 2010 at 4:28 AM

Great... it took me a little while to realize I could use Storage.Set<T>(string name, T value). So what are the possible T types other than string? I tried a simple custom type and it didn't work.