Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Umbraco Newbie 22 posts 124 karma points
    Sep 01, 2017 @ 06:43
    Umbraco Newbie
    0

    Doc Type Editor With Nested Content Display Content in Back Office Throws Null Reference Exception Front End

    Hi

    Umbraco 7.6.5

    Has anyone else has this problem. I can see the content update the content in the back office, put a break point on the code and get 3 records returned.

    But if I try to see the content on the home page no data is returned and I get a null reference exception thrown.

    Below is the json getting returned

    {
      "name": "1 column layout",
      "sections": [
        {
          "grid": 12,
          "rows": [
            {
              "label": "Headline",
              "name": "Headline",
              "areas": [
                {
                  "grid": 12,
                  "allowAll": false,
                  "allowed": [
                    "docType",
                    "carousel",
                    "singleItem"
                  ],
                  "hasConfig": false,
                  "controls": [
                    {
                      "value": {
                        "dtgeContentTypeAlias": "carousel",
                        "value": {
                          "name": "Carousel",
                          "carouselItem": [
                            {
                              "name": "text line 1",
                              "ncContentTypeAlias": "carouselItem",
                              "textToDisplay": "text line 1"
                            },
                            {
                              "name": "text line 2",
                              "ncContentTypeAlias": "carouselItem",
                              "textToDisplay": "text line 2"
                            },
                            {
                              "name": "Item 3",
                              "ncContentTypeAlias": "carouselItem",
                              "textToDisplay": "text line 3"
                            }
                          ]
                        },
                        "id": "1b12e865-9e79-53c0-90ad-8cfcf9b57e2c"
                      },
                      "editor": {
                        "alias": "carousel"
                      },
                      "active": false
                    }
                  ]
                }
              ],
              "hasConfig": false,
              "id": "05f61a2d-43d8-ad45-af7d-cd9440e665fc"
            },
            {
              "label": "Headline",
              "name": "Headline",
              "areas": [
                {
                  "grid": 12,
                  "allowAll": false,
                  "allowed": [
                    "docType",
                    "carousel",
                    "singleItem"
                  ],
                  "hasConfig": false,
                  "controls": [
                    {
                      "value": {
                        "dtgeContentTypeAlias": "singleItemCase",
                        "value": {
                          "name": "Single Item",
                          "textCase": [
                            {
                              "name": "Item 1",
                              "ncContentTypeAlias": "singleItem",
                              "textToDisplay": "test for single item"
                            }
                          ]
                        },
                        "id": "2d174b11-a9a5-9cfa-dee5-8d7fbd47fc47"
                      },
                      "editor": {
                        "alias": "singleItem"
                      },
                      "active": true
                    }
                  ],
                  "active": true
                }
              ],
              "hasConfig": false,
              "id": "b4b87e41-8ad3-d6df-c9c7-612ddb74ddea",
              "hasActiveChild": true,
              "active": true
            }
          ]
        }
      ]
    } 
    

    Code used:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    <h1>Carousel Text Been Displayed in Backoffice</h1>
    @{
        var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("carouselItem");
    
        foreach (var item in items)
        {
            <h3>@item.GetPropertyValue("textToDisplay")</h3>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft