In the first post in this series, we’ve looked at the most difficult way to create relationships in Orchard. In this post, we’ll look at the easiest: content item picker field.
To start using a content item picker field, just head over to the content definitions, edit a content type, and add the field:
Once this is done, you can expand the settings for the field, and configure it:
As you can see, you can set the cardinality of the relationship there: you can specify if zero, one, or more related items are permitted. In the bottom textbox, you can specify what related contents are allowed.
Once you’ve saved the content type definition, you can start adding related contents from the content item editor, removing them, or re-ordering them:
The content item picker field makes things really easy. Let's recap...
- Super-easy, no code to write, except for front-end template overrides in the theme.
- Allows for more than one relationship per type.
- Only works between content items.
- Can’t query on related items except with Projections, or similar techniques.
- Can't customize the admin user experience.
You can use content picker any time you need to establish relationships between content items, but don’t need to query on the relationship other than using Projections. You also need to be OK with the standard UI that comes with the content picker: it’s going to be that list of items, with the picker popup. You can’t have checkboxes, drop-downs, or type-ahead experiences.