Retrieving content types
Getting a single content type
A given content type has a few different unique identifier that we can use to look it up via the content type service. For instance, if we know the GUID of the content type, we can look it up like this:
Although the use of a GUID is preferable, you can also use it's numeric ID:
Finally, you can also look up a content type by its alias:
Getting a list of content types
As content types are stored in a hierarchical list with folders (containers), there is also multiple ways to can get content types. If you are looking for a flat list of all content types, you can use the GetAll
method:
In the example above, the method was called without any parameters. The method also has two overloads, which lets you look up a collection fo content types by either specifying their GUID or numeric IDs:
To get a list of all content types of another content type, you can instead use the GetChildren
method - either by specifying the numeric ID or the GUID:
Check whether a content type has children
In some cases it can be useful to check if a content type has children. The HasChildren
method can be used to check whether a content type has children.
Although the use of a GUID is preferable, you can also use it's numeric ID:
Last updated