Expand my Community achievements bar.

Apply page content type validation to Content Reference in Content Fragment Model

Avatar

Level 3

When creating a Content Fragment Model there is a data type of "Content Reference". This allows the content author to browse and select content within AEM. The data type has validation options where only specific content types are allowed in the property. 

 

Make this field only accept specific content types:

  • Content Fragment
  • Plain Text
  • Rich Text
  • Image
  • Audio
  • Video
  • PDF Document
  • Spreadsheet
  • Presentation
  • Archive
  • Markup

In our case we are hybrid headless so much of the content is traditional pages. We have a use-case in a content fragment where the user should only select a Page. Is there any way to do so?

 

AEM 6.5.17

AEM 6.5.18

 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Administrator

There is a way to make the "Content Reference" field in a Content Fragment Model only accept specific content types, including Page. To do this, you will need to use the "Allowed Content Models" validation option. This option allows you to specify a list of content models that are allowed to be referenced in the property.

To make the field only accept the specific content types you listed, you would add the following content models to the "Allowed Content Models" list:

  • ContentFragment
  • PlainText
  • RichText
  • Image
  • Audio
  • Video
  • PDFDocument
  • Spreadsheet
  • Presentation
  • Archive
  • Markup
  • Page

This will ensure that the content author can only select content from these models when editing the property.

Here are the steps on how to add the "Allowed Content Models" validation option:

  1. Open the Content Fragment Model in the AEM Content Editor.
  2. Select the property that you want to restrict.
  3. In the "Validation" section, click the "Add Validation" button.
  4. Select "Allowed Content Models" from the list of validation types.
  5. In the "Allowed Content Models" field, enter the names of the content models that you want to allow, separated by commas.
  6. Click the "Save" button.

Once you have added the "Allowed Content Models" validation option, the content author will only be able to select content from the specified models when editing the property.



Kautuk Sahni

Avatar

Level 3

Thanks for the reply!

 

It is possible I am missing something, but I don't think the instructions work on AEM 6.5.17 or 6.5.18. Perhaps this is a cloud solution?

 

A few notes though...

 

Regarding this:

To do this, you will need to use the "Allowed Content Models" validation option. This option allows you to specify a list of content models that are allowed to be referenced in the property.

To make the field only accept the specific content types you listed, you would add the following content models to the "Allowed Content Models" list:

  • ContentFragment
  • PlainText
  • RichText
  • Image
  • Audio
  • Video
  • PDFDocument
  • Spreadsheet
  • Presentation
  • Archive
  • Markup
  • Page

 


Since a page is not a content fragment I am using a Content Reference instead of a Fragment Reference. From what I can tell, the ability to select and restrict the allowed content models would not apply in this case. I think the items listed in the drop down and shown in the bulleted list for this post are content types not fragment models. A content model would be a model created by an administrator or super user such a Adventure, Author or Article on the WKND site. Image, Audio, PDF Document, etc would be  content types.

 

ClintLundmark_2-1700157043594.png

 

As noted originally, when creating a Content Reference data type, page is not a validation choice for "Accept only specified content types"

 

ClintLundmark_0-1700156930398.png

 

ClintLundmark_1-1700156946913.png