Related data custom field
You use the Related data custom field to relate one content item to another. Then, you can make related items to be displayed as a link on the frontend.
EXAMPLE: You have a dynamic module Authors. The module stores information about different authors. Create a page where you drop the Authors widget. Open the News module and create a custom field of type Related data and Data type Authors. In the backend, when you create a news item, you see the custom field added. There you can choose an author that will be related to the news item. Then, you add the Authors field to the widget template of the News widget. When you open the site and click a news item, you will see the details of the news item and the link to the author’s details.
To add a Related data custom field, perform the following:
- Perform procedure Create custom fields » Step 1 to Step 5.
- In Data type dropdown box, select the data type which you want to relate.
You can select dynamic data types, built-in data types, and pages.
For example, you can relate Events to News or Pages, or you can relate them to a dynamic type, created with the Module builder.
- Click Continue.
The Add a field window appears.
- In Allow selecting items from..., select the provider where you want to store the related media items.
- Under Interface widget for selecting items, select the widget that you want to use in the backend to select the related item.
Depending on the data type, it can be a content or page selector.
- In the Label input field enter the label of the selector.
This label is displayed when you create a content item in the backend.
For example, Related items.
- In Instructional text, enter instructions or explanatory text for the custom field, if needed.
The text is displayed when the content editor clicks the question mark icon in the backend when editing the item containing this custom field.
- Select the This is a required field checkbox, if you want to make the custom field mandatory.
- Select the Multiple items from this data type can be related checkbox to enable the content editors to relate multiple items. Unchecking it limits the relationship to just one item.
- Click Done.
The new field appears in Custom fields section.
If you want to delete a custom field, click .
- Save your changes.
- Insert the custom field in the respective widget template.
For example, if you want to relate News to Author, you must insert the Authors custom field in the widget template that you use to display news items.
For more information, see Create and edit widget templates.
Deleting an item with related data custom fields
When you delete an item that has related data custom field added to it, you can choose to display a warning message. This way, you can avoid breaking links from other content items or pages.
To do this, perform the following:
- Click Administration » Settings » Advanced.
- In the tree on the left, click RelatedData and select Display a warning message to prevent users from deleting items that are related to another items checkbox.
- Save your changes.