How to Create Relationships between Content

Follow

This article is targeted for developers, architects and advanced editors who create and manage content/module definitions within the CMS.

Agility allows you to add fields to your content/module definitions. When editors are creating and updating content, they utilize these fields to enter and save content. While basic field types include Text, HTML, Image, and URL, Agility also provides a special field type called Linked Content

Linked Content allows you to create relationships between your content item and one or many other content items. When you select the Linked Content field type, there are several different ways you can render this field type and how editors can interact with other content. This could be simply linking to an entire list, rendering a grid view, or allowing editors to select items from a checkbox list, dropdown list, or search list box.

When to use Linked Content

There are various reasons why you might want to use a Linked Content  field:

  • You want editors to be able to manage a list of categories and then also be able to associate other content items to a category (i.e. a Blog Post and a Category)
  • You want to allow editors to create one or many items associated to a single content item (i.e. slides in an image slider)
  • You want to provide a shortcut from a content item to another content item or list directly 
  • You want to allow an editor to select a subset of items from another list in a specific order

It's important to note that Linked Content fields can be used in Content Definitions as well and Module Definitions.

Dropdown Field using Linked Content

Consider the following use case:

We want to allow an editor to associate a Product to a Product Category in the CMS. A Product is limited to having only one category.

We can achieve this by adding a Linked Content field to our Product definition that will render as a dropdown and link to our list of Product Categories. When the editor selects a category, the Content ID of that category will be saved in a corresponding field in the input form. That Content ID will then be available to the developer when accessing the Product in code on the website.

How to Create a Dropdown Linked Content Field

  1. Login to the Agility Content Manager

  2. Ensure you have your content that you want to link to (i.e. Product Categories in this case)  already setup and initialized in Shared Content

  3. Navigate to your Content Definition in Settings > Content Definitions, in this case it is our Product content definition

  4. On the details of the definition, select the Form Builder tab and add a new Number field called Product Category ID, this will be the field used to store the ID of the selected content item. Ensure you set the Hide Field from Input Form property to Truethere is no reason to show this field to editors.

  5. Click Save & Close to apply your new field

  6. Add another new field called Product Category, this will be your linked content, dropdown field. Ensure you set the Field Type to Linked Content

  7. Select the name of your Content Definition (in this case Product Category)

  8. Select an instance of the list from Shared Content (in this case Product Categories)

  9. For Render As, select Dropdown List

  10. Lastly, you need to set the Save Value to Field to your ID field that you created in the previous step (in this case, Product Category ID)

  11. Click Save & Close to apply your changes.

  12. Now navigate to your list of content that has the linked content field and open an existing item or new item, you should see the dropdown list field being rendered.

Checkbox List Field using Linked Content

Consider the following use case:

We want to allow an editor to associate a Product to one or many Product Tags in the CMS.

We can achieve this by adding a Linked Content field to our Product definition that will render as a checkbox list and link to our list of Product Tags. When the editor selects one or many tags, the Content IDs the selected tags will be saved in a corresponding field in the input form. The Content IDs will then be available to the developer when accessing the Product in code on the website.

How to Create a Checkbox List Linked Content Field

  1. Login to the Agility Content Manager

  2. Ensure you have your content that you want to link to (i.e. Product Tags in this case)  already setup and initialized in Shared Content

  3. Navigate to your Content Definition in Settings > Content Definitions, in this case it is our Product content definition

  4. On the details of the definition, select the Form Builder tab and add a new Text field called Product Tags IDs, this will be the field used to store the IDs of the selected content items (tags). Ensure you set the Hide Field from Input Form property to Truethere is no reason to show this field to editors.

  5. Click Save & Close to apply your new field

  6. Add another new field called Product Tags, this will be your linked content, checkbox list field. Ensure you set the Field Type to Linked Content

  7. Select the name of your Content Definition (in this case Product Tag)

  8. Select an instance of the list from Shared Content (in this case Product Tags)

  9. For Render As, select Dropdown List

  10. Lastly, you need to set the Save Value to Field to your ID field that you created in the previous step (in this case, Product Tags IDs)

  11. Click Save & Close to apply your changes.

  12. Now navigate to your list of content that has the linked content field and open an existing item or new item, you should see the checkbox list field being rendered.

 

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.