Try our conversational search powered by Generative AI!

Nested block ContentReference not returning by content delivery API

Vote:
 
Given I have a page type 'TestPage' that has one property which is a ContentReference to a block type 'TestBlock' which in intself has a ContentReference to another TestBlock
The content delivery API does not return the referenced ContentReference from the block.  The page ContentReference is returned and expanded but the block is not.
Is there anything I can do to get the full nested ContentReferences?
Here are the Page/Block types for example:
[ContentType(GUID = "F40176A2-E3A2-43F8-A18B-2A133D5D8BBC", DisplayName = "Test Page")]
public class TestPage : PageData
{
    [AllowedTypes(typeof(TestBlock))]
    [Display(Name = "Child", Order = 10)]
    public virtual ContentReference Child { get; set; }
}

[ContentType(GUID = "9DDFEF96-AB5B-42CD-80D0-31D9E65ADAE6", DisplayName = "Test Block")]
public class TestBlock : BlockData
{
    [Display(Order = 5)]
    public virtual string Heading { get; set; }


    [Display(Name = "Child", Order = 10)]
    [AllowedTypes(typeof(TestBlock))]
    public virtual ContentReference Child { get; set; }
}

This is an example response when calling the content delivery API with an expand property set to '*'. See that the first block from the page is expanded but the second is not (i've commented the JSON).

{
  "contentLink": {
    "id": 202,
    "workId": 0,
    "guidValue": "5ff3fc26-7a31-4820-b947-2a918e222065",
    "providerName": null,
    "url": "/test/",
    "expanded": null
  },
  "name": "Test",
  "language": {
    "link": "/test/",
    "displayName": "English",
    "name": "en"
  },
  "existingLanguages": [
    {
      "link": "/test/",
      "displayName": "English",
      "name": "en"
    }
  ],
  "masterLanguage": {
    "link": "/test/",
    "displayName": "English",
    "name": "en"
  },
  "contentType": [
    "Page",
    "TestPage"
  ],
  "parentLink": {
    "id": 5,
    "workId": 0,
    "guidValue": "1611ac34-e475-41fe-b278-1be758763003",
    "providerName": null,
    "url": "/",
    "expanded": null
  },
  "routeSegment": "test",
  "url": "/test/",
  "changed": "2022-02-25T12:02:15Z",
  "created": "2022-02-25T12:02:06Z",
  "startPublish": "2022-02-25T12:02:15Z",
  "stopPublish": null,
  "saved": "2022-02-25T12:04:54Z",
  "status": "Published",
  "category": [],
  "requiresAuthentication": null,
  "meta": {
    "title": "",
    "description": "",
    "robots": ""
  },
  "child": { // this is the first block referenced by the page
    "id": 204,
    "workId": 0,
    "guidValue": "ca5cae7a-06af-420d-806d-0c9a49e36b43",
    "providerName": null,
    "url": null,
    "expanded": {
      "contentLink": {
        "id": 204,
        "workId": 0,
        "guidValue": "ca5cae7a-06af-420d-806d-0c9a49e36b43",
        "providerName": null,
        "url": null,
        "expanded": null
      },
      "name": "Test 1",
      "language": {
        "link": null,
        "displayName": "English",
        "name": "en"
      },
      "existingLanguages": [
        {
          "link": null,
          "displayName": "English",
          "name": "en"
        }
      ],
      "masterLanguage": {
        "link": null,
        "displayName": "English",
        "name": "en"
      },
      "contentType": [
        "Block",
        "TestBlock"
      ],
      "parentLink": {
        "id": 203,
        "workId": 0,
        "guidValue": "0fd61ab0-e440-4084-88ab-4eeefcd35c66",
        "providerName": null,
        "url": "/contentassets/0fd61ab0e440408488ab4eeefcd35c66/",
        "expanded": null
      },
      "routeSegment": null,
      "url": null,
      "changed": "2022-02-25T12:02:59Z",
      "created": "2022-02-25T12:02:37Z",
      "startPublish": "2022-02-25T12:02:59Z",
      "stopPublish": null,
      "saved": "2022-02-25T12:05:07Z",
      "status": "Published",
      "category": [],
      "heading": "Test 1",
      "child": { // here is the child property of the block which should be another block with a heading etc. but 'expanded' is null?
        "id": 206,
        "workId": 0,
        "guidValue": "5f05d107-8973-46c6-9e37-3c71729d283a",
        "providerName": null,
        "url": null,
        "expanded": null
      }
    }
  }
}
#274548
Feb 25, 2022 14:24
Vote:
 

Not ideally to have multiple nested blocks for content delivery for performance reasons- by default it will only expands to 1 level . you can cetainly customise but I would rather perfer not to have that level of nesting and consider remodeling.

#275957
Mar 09, 2022 10:13
Vote:
 

We have remodelled but I would be interested to know how to configure it anyway in case we need it in future?  I can't find anything in the documentation to let me know how to configure it?

#275958
Mar 09, 2022 11:11
* 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.