What is related content

The following section describes what you need to know when using related content in your modules or pages.

Meta information

When you create a Related data custom field, the system creates a corresponding meta field. Meta fields in Sitefinity CMS are stored in the [sf_meta_fields] table. The meta field has a property AllowMultipleRelations, which defines whether the field allows multiple items to be related. Meta fields for Related data custom fields are created with the following meta attributes: 

  • RelatedType - stores the type of the Related data field.
  • RelatedProviders - stores the provider of the Related data field.
  • ControlTag - this is the tag template that is generated for the widget templates. 

Related data field controls and widgets

Related data custom fields use separate controls to display relations in the backend and the frontend. By default, the RelatedDataField control is used to display and edit related data in the backend. The control is located in Telerik.Sitefinity.Web.UI.Fields namespace. 

Depending on the type of the relation, different frontend widgets are used. For example, if you have created a relation to a News content, the News widget is one of the options for displaying the relation in the frontend. Another option is to use the default Simple link widget, which is only a simple repeater for the items.

Following is the code for the generated custom field template:

Property descriptor

The property descriptor for related data fields is called RelatedDataPropertyDescriptor. The GetValue method of the property descriptor returns the actual related items (not the content links). The property descriptor also applies filter for the status of the related items, which depends on the status of the parent item. This means that, if the parent item’s status is Master, only

Master related items are returned. If the request is made from a widget in the frontend, only live and visible items are returned.

Content links 

When you create a relation to an item, the system creates a content link that is made available for the current state of the parent item. The content link represents the relation and contains information about both the parent item (ParentItemType, ParentItemProviderName, ParentItemId, ParentItemAdditionalInfo) and the child item (ChildItemType, ChildItemProviderName, ChildItemId, ChildItemAdditionalInfo) of the relation. 

You can order item relations created via content links directly from the user interface. The specified order of the related items is saved in the ordinal property of the created content links. 

The name of the Related data field is used to specify the ComponentPropertyName of the content links that are displayed in the RelatedDataField. As a result, many relations can be added to different content types via different fields.

Content links have three properties:

  • AvailableForTemp – marks whether the content link is available for the Temp version of the item.
  • AvailableForLive - marks whether the content link is available for the Live version of the item.
  • AvailableForMaster - marks whether the content link is available for the Master version of the item.

Ordering 

You can order related items from the user interface using drag-and-drop of the RelatedDataField. Updated ordinals are saved to the ordinal property of the created content link. 

If there are no other filters applied, related items are displayed on the frontend in the same order as they are displayed in the backend.

Parent and child 

The parent is defined as the item that contains the RelatedData field and the child is the item that is being related to the parent item. For example, if you add a custom RelatedDataField to a Sessions content type and set its Data type to be Locations, when you create a new session, you will have the option to select related locations. In this case, the session item will be the parent and the location – the child.  

In the backend, you can see the child items displayed via the RelatedDataField control in the details view of the parent item. Parent items, on the other hand, are displayed in the details view of the child item on the right, under the link Items linking to this item.

In the frontend, related items are displayed by adding the related data field to the widget template of the parent item. For dynamic parent items, this happens, by default, when the widget templates are regenerated. For static parent items, such as News or Events, you need to manually insert the automatically generated field template to the parent widget template. 

Status flags 

If item relations are created through the user interface, content links are marked as available for the Temp state. When the parent item is saved as draft or published, the content links’ availability statuses change from Temp to Master and finally to Live. This ensures that different related items can be supported for different parent item’s statuses. 

If item relations are created through the Related data API (defined in the RelatedDataExtensions class), the status of the content link is set to the status of the parent item. In this case, you have to ensure the transition to statuses other than this.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?