Probably in every EPiServer project there will be a need to store a list of links to your content pages. EPiServer.CMS.UI 8.6.0 introduced a new multiple ContentReference property. Usually we could use a single property to store a collection of links. For example when building a media slideshow or when displaying links in a site footer. Using EPiServer there are several possibilities of implementation. Until now there were two built-in properties – ContentArea and LinkItemCollection, and the new multiple ContentReference is yet another interesting solution. I’ll try to compare those properties.

LinkItemCollection

LinkItemCollection has been a part of EPiServer for a long time. It’s much older than dojo based edit mode. Elements are stored as a list of URLs. Link could be an internal page, media, external link, or email. It is possible to define title and target for all the links.

edit mode ContentArea

Using LinkItemCollection on content model:

ContentArea

ContentAreas are used to store a list of content references. They support customozation with display options and visitor groups.

edit mode LinkItemCollection

Using ContentArea on content model:

ContentArea backing type doesn’t implement the IEnumerable interface like LinkItemCollection. To get the access to items we need to use Items or FilteredItems properties. Items returns all elements stored in ContentArea. FilteredItems returns elements filtered by publish status, permissions and personalization.

Multiple content reference

Multiple ContentReference property stores list of Content References. It’s similar to ContentArea, but much simpler. There is no support for visitor groups and display options. This property has no custom backing type like for ContentArea and LinkItemCollection. The backing type is a standard IList .NET framework type (or another covariant type).

edit mode content references

Using multiple ContentReferences:

Client side model

The elements stored in ContentArea and LinktemCollection properties have several configuration options. Each element has a reference to the linked object, but also settings for the element like roles in ContentArea item. That’s why the underlying property model is complex. Below is an example of JSON model for ContentArea:

And for the LinkItemCollection:

Multiple references list stores collection of content references without additional configuration. The underlying model is very simple – it’s an array of ContentReferences objects

When preparing custom editor for this property it should be easy to transfer model value to server. For ContentArea and LinkItemCollection it’s much more difficult.

Comparing features

All of list properties described above have some common features:

  • They allow to sort elements – when iterating property value, the elements are returned as ordered collection.
  • The list elements are indexed with SoftLink – editor will get warning message when try to delete content that is referenced in property.
  • They support storing Pages and Media content.
  • You could use D&D to add content

There are some differences between those properties. I group them and described in the table below.

Feature References list ContentArea LinkItemCollection
AllowedTypesAttribute

content references - AllowedTypes

Yes Yes No
Shows content thumbnail in edit mode

content references - thumbnail

Yes No No
Allow to store blocks

content references - DandD blocks

Yes Yes No
Creating a block directly from property

content references - create block

No Yes No
Browsing Content throught the dialog tree window

content references - browse dialog

Yes No Yes
Storing external URL’s

content references - external URL

No* No* Yes
Storing link elements

content references - storing data

ContentReference ContentReference URL
Property implements IEnumerable

content references - ienumerable

Yes No (Items, FilteredItems) Yes

* It’s possible to store external URL using ContentArea or content references list. For example we could create a new block type. Inside block model add string property used to store URL value. And then add instance of the block to ContentArea.

Summary

There are a few properties that could be used to store a list of contents. If the requirement is to store plain list of content references, like when implementing images carousel, then the best option could be the new multiple content references property. It has a simple backing type model and no configuration overhead. Also the editor layout contains interesting information like published date, thumbnail and type name.

For more complex scenarios like list when element should be displayed based on visitor group the ContentArea property could be a better choice. It’s heavier than the multiple references list, but has more features.

To store a simple list of links that contains content references or external URL’s we should use LinkItemCollection.