Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add nested block list in block grid content programmatically in Umbraco 13 #17150

Closed
ben-umble opened this issue Sep 27, 2024 · 2 comments
Labels

Comments

@ben-umble
Copy link

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.5.0

Bug summary

I'm attempting to create some Block Grid content for a node with the property of pageBody.

I've got this working by using the Content Service and it's working nicely for the most part.

I have a structure that looks like this:

  • Row
    • Column
      • Editor
  • Column
    • Editor

The editors in this case are a custom doc type used to build a carousel.

To create the structure and content I'm creating a JSON object which follows the Block Grid content structure and it's all working nicely until it comes to creating the block list items which represent each slide.

This is the JSON that I'm using to create the block grid:

{
  "layout": {
    "Umbraco.BlockGrid": [
      {
        "contentUdi": "umb://element/9b607641d0794014bd4624633bdf0bc1",
        "settingsUdi": "umb://element/94e04102756f469c820a596d6ec32ccd",
        "areas": [
          {
            "key": "6c8edc61-b52f-375b-b805-91746c66ce1c",
            "items": [
              {
                "contentUdi": "umb://element/34e47a1023404389bdfdc437f3e46038",
                "columnSpan": 0,
                "rowSpan": 0,
                "areas": [
                  {
                    "key": "469abcec-0c05-3e54-b0d5-6475308649d1",
                    "items": [
                      {
                        "contentUdi": "umb://element/9f80b0d085e84fcdaff056826a61c6fe",
                        "columnSpan": 6,
                        "rowSpan": 1,
                        "areas": [],
                        "settingsUdi": "umb://element/cee1cdd9cf9a4220851ca14f003f49a7"
                      }
                    ]
                  },
                  {
                    "key": "1dcb2bbb-d383-37a1-90fc-d5083d16778d",
                    "items": [
                      {
                        "contentUdi": "umb://element/94e844d9e67b482fbe5bc6a98f43fc86",
                        "columnSpan": 6,
                        "rowSpan": 1,
                        "areas": [],
                        "settingsUdi": "umb://element/ee9c940313e2457c9058d3bb62cc6284"
                      }
                    ]
                  }
                ],
                "settingsUdi": null
              }
            ]
          }
        ]
      }
    ]
  },
  "contentData": [
    {
      "contentTypeKey": "e09e94a3-3697-42c6-9a4d-eb8631e35f05",
      "udi": "umb://element/9f80b0d085e84fcdaff056826a61c6fe",
      "carouselSlides": {
        "layout": {
          "Umbraco.BlockGrid": [
            {
              "contentUdi": "umb://element/23851b764ede47cf84b536bd9fdc1c96"
            }
          ]
        },
        "contentData": [
          {
            "contentTypeKey": "0bb6d398-44cd-4699-81ee-1ee8fb2362a8",
            "udi": "umb://element/23851b764ede47cf84b536bd9fdc1c96",
            "carouselHeading": "Test",
            "carouselImage": "umb://media/515526e502d64d33bb3a3cf993d25b19"
          }
        ],
        "settingsData": []
      }
    },
    {
      "contentTypeKey": "65b260e3-2060-3376-9182-277a3566c721",
      "udi": "umb://element/77ebac535c9849f78b9d4f54fa058c61"
    },
    {
      "contentTypeKey": "e09e94a3-3697-42c6-9a4d-eb8631e35f05",
      "udi": "umb://element/94e844d9e67b482fbe5bc6a98f43fc86",
      "carouselSlides": {
        "layout": {
          "Umbraco.BlockGrid": [
            {
              "contentUdi": "umb://element/66244dfd6c7a40b0a2a634495ff0e754"
            }
          ]
        },
        "contentData": [
          {
            "contentTypeKey": "0bb6d398-44cd-4699-81ee-1ee8fb2362a8",
            "udi": "umb://element/66244dfd6c7a40b0a2a634495ff0e754",
            "carouselHeading": "Test",
            "carouselImage": "umb://media/515526e502d64d33bb3a3cf993d25b19"
          }
        ],
        "settingsData": []
      }
    }
  ],
  "settingsData": []
}

This creates the rows, the columns, and the carousel but the carouselSlides property is empty.

For comparison, an example of the slides I'm trying to create look like this:

{
  "contentTypeKey": "e09e94a3-3697-42c6-9a4d-eb8631e35f05",
  "udi": "umb://element/9f80b0d085e84fcdaff056826a61c6fe",
  "carouselSlides": {
    "layout": {
      "Umbraco.BlockGrid": [
        {
          "contentUdi": "umb://element/23851b764ede47cf84b536bd9fdc1c96"
        }
      ]
    },
    "contentData": [
      {
        "contentTypeKey": "0bb6d398-44cd-4699-81ee-1ee8fb2362a8",
        "udi": "umb://element/23851b764ede47cf84b536bd9fdc1c96",
        "carouselHeading": "Test",
        "carouselImage": "umb://media/515526e502d64d33bb3a3cf993d25b19"
      }
    ],
    "settingsData": []
  }
}

If I create the content manually and get the data back, it comes back like this:

{
  "contentTypeKey": "e09e94a3-3697-42c6-9a4d-eb8631e35f05",
  "udi": "umb://element/8d04bbe17cc84a6f8ec024a2cdf6e521",
  "displayControls": 0,
  "autoPlay": 1,
  "carouselSlides": {
    "layout": {
      "Umbraco.BlockList": [
        {
          "contentUdi": "umb://element/ccc99d993bfc4faea384eb03becb6b78"
        }
      ]
    },
    "contentData": [
      {
        "contentTypeKey": "0bb6d398-44cd-4699-81ee-1ee8fb2362a8",
        "udi": "umb://element/ccc99d993bfc4faea384eb03becb6b78",
        "carouselHeading": "test",
        "carouselImage": "umb://media/515526e502d64d33bb3a3cf993d25b19"
      }
    ],
    "settingsData": []
  }
}

This structure looks to match, but it simple won't appear on the content when I view it in the UI.

This is how I'm saving the content:

string gridString = JsonSerializer.Serialize(newGrid, new JsonSerializerOptions { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });

node.SetValue("pageBody", gridString);

_contentService.SaveAndPublish(node);

There are no errors and everything saves but not the carousel slides.

I'm not certain if this is a bug or a problem with the structure of my code but I can't get it to work even though I'm passing in the JSON which looks the same as the working version that is returned from the node property if I create the grid manually.

Specifics

No response

Steps to reproduce

  1. Create a new block grid data type
  2. Create configurations for a Full Width Row, and an Article row which contains two areas side-by-side
  3. Create a carousel slide doc type with just text as the property
  4. Create a carousel doc type which has one property of carouselSlides, this should be a block list editor making use of the slide doc type in step 3
  5. Allow Article row to be created inside the Full Width row
  6. Allow the carousel editor to be created inside the Article row
  7. Add a new doc type Home with a property of pageBody which should be the new block grid type we created earlier
  8. Use the content service to save the content using the above JSON example as the basis

Expected result / actual result

The carouselSlides property should have a slide with some text set but no matter what I try, this property seems to be empty always.

Copy link

Hi there @ben-umble!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@ben-umble
Copy link
Author

Well, I went for a walk and got thinking and suddenly realised my very silly mistake, Umbraco.BlockGrid should be UmbracoBlockList.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant