Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Unable to restrict content types using ContentDefinitions API

Vote:
 

Hi,

I was playing around with the Content Definitions API and tried to create a list of custom block type or a content area restricted to a specific block type. I am unable to get it to work though. I provide some examples:

The code below creates a TextArea in the edit view so there's no way to create a new block...

{
    "name": "ListOfBlocks",
    "datatype": "PropertyCollection",
    "itemType": "MyCustomBlock",
    "branchSpecific": false,
    "editSettings": {
        "displayName": "Create Blocks",
        "groupName": "Information",
        "sortOrder": 10
    }
}

Then I tried to create a content area using the code below. However, I can't find a way to restrict the allowed types (using the API).

{
    "name": "ContentArea",
    "datatype": "PropertyContentArea",
    "itemType": "MyCustomBlock",
    "branchSpecific": false,
    "editSettings": {
        "displayName": "Select Content",
        "groupName": "Information",
        "sortOrder": 10
    }
}
#296117
Edited, Feb 07, 2023 14:54
Vote:
 

I tested this scenario on an Alloy site. Added the contact block list as an IList to the article page and checked the content definitions using the API

[Display(
    Name = "Kontakter",
    GroupName = SystemTabNames.Content,
    Order = 120)]
[AllowedTypes(AllowedTypes = new[] { typeof(ContactBlock) })]
public virtual IList<ContentReference> Contacts { get; set; }

The content definition (https://localhost:5000/api/episerver/v3.0/contenttypes/aeecadf2-3e89-4117-adeb-f8d43565d2f4)

{
    "name": "Contacts",
    "dataType": "PropertyContentReferenceList",
    "branchSpecific": false,
    "editSettings": {
        "visibility": "default",
        "displayName": "Kontakter",
        "groupName": "Information",
        "sortOrder": 120
    }
},

So looking at the documentation and also decompiling the content definition binary the support for complex attributes seems not to be supported.

#296284
Feb 09, 2023 22:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.