In my previous post we used the example of a film to show you how to create a simple content type. In this post I'll outline how we can create relationships between two content types to build a simple content model, and make your content easy to reuse.
We'll continue along the theme of films and introduce the cast and crew.
Extend the existing content type
One way we could add the cast and crew would be to extend the existing film content type. Adding additional text fields to the content type would allow an author to supply key cast and crew members, but this could severely reduce the reuse and flexibility of the content. Lets look at some reasons why.
Limitations of adding static fields
- You would have to predefine a set number of actor text fields, e.g. 5, but what happens when you need to add 6 actors?
- An author would have to manually type the name of each actor, leading to potential spelling mistakes and duplication.
- Using a comma-separated list in a text field would allow you to add multiple people, but this method this is prone to error.
- What if an actor appears in multiple films? This is another situation where an author is likely to introduce spelling inconsistencies between different films.
- It provides no way to extend an actor / crew member's details at a later date, e.g. biography, date of birth and place of birth.
A better way, make content flexible
If you have a type of content that has the potential to be extended, then its a good idea to create a new content type. This ensures that your content remains as flexible as possible and ready for reuse. Combining the content types by creating a content type relationship extends the basic content model we saw in my last post.
In our example both cast and crew are people defined by a particular role in a film. So, we'll create a content type called people that we can then relate to specific roles in our film content type.
People content type
We'll include the following fields in the content type:
||The name of the film.
||A short biography for the individual.
|Date of birth
||The date that the individual was born.
Connecting people to their roles
Now we have two content types, we need to create a relationship between the people and their relevant roles in the film.
We can use the entry field type to create this relationship. The entry field editor allows single or multiple entries to be selected from a content type, allowing an author to create a relationship between two different sets of content.
Adding multiple cast members to a film
For the purposes of this post I've created a couple of example cast members by creating new entries against the people content type.
Once the relationship is in place an author can easily select people using the autosuggest search box when populating the entry.
Using a new content type and setting up a relationship creates content flexibility. New people can be added centrally, updates can be made to their information, and people can be assigned to multiple roles or used in other content types by creating new relationships.
Breaking your content down into smaller chunks is fundamental to making your content easy to reuse and manage across your websites or applications.
Signup to the Contensis BETA and build your own
If you are already a user of Contensis, you can have a go at creating your own content models for your organisation in Contensis 9 by signing up to our BETA.