Copied to clipboard

Flag this post as spam?

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


  • Heather Floyd 605 posts 1006 karma points MVP 5x c-trib
    Nov 30, 2022 @ 20:47
    Heather Floyd
    0

    Block List Labels: Is there any way to "bubble up" child Block labels?

    I have a Block List on a Document Type with 3 available blocks (1Col, 2Col, & 3Col). Each of those three blocks has some inner Block List properties (aka nested Block Lists). For the label on the three main types, I would love to just show the label which is visible on the FIRST nested block. Is there any way to achieve this?

    For example, if I choose a block of type "1Col", I can make a Label like this:

    {{$index}}{{$settings.umbracoNaviHide == 1 ? ' DISABLED' : ''}} - 1 Column Row
    

    I'd like to append the label of the first item in the "Col1Content" property (say, for instance, an RTE, which has it's own custom Label)

    I've tried :

    {{Col1Content[0].Label}}
    

    Which, I know, was a bit of a long-shot... ;-)

    The stored JSON for the property looks like this:

    {
       "layout":{
          "Umbraco.BlockList":[
             {
                "contentUdi":"umb://element/91e9986b17284025abc10186edbeea5a",
                "settingsUdi":"umb://element/1623d9dee3f940e2973f1a7065abb41c"
             }
          ]
       },
       "contentData":[
          {
             "contentTypeKey":"8ab7b342-19fa-4c29-98e9-eda5f835d00f",
             "udi":"umb://element/91e9986b17284025abc10186edbeea5a",
             "PaddingCol1":null,
             "Col1Content":"{\"layout\":{\"Umbraco.BlockList\":[{\"contentUdi\":\"umb://element/3afcc0230fbb4dda956ec4413cac5551\",\"settingsUdi\":\"umb://element/75accad9c96c4e32a59f3b2daaa659ae\"}]},\"contentData\":[{\"contentTypeKey\":\"9ed671c2-5298-4621-8844-158f3fcd6ca8\",\"udi\":\"umb://element/3afcc0230fbb4dda956ec4413cac5551\",\"BlockName\":\"My Custom Block name\",\"HeadingLevel\":\"h1\",\"Header\":\"My Header\",\"Subheader\":null,\"Alignment\":null}],\"settingsData\":[{\"contentTypeKey\":\"57e2218c-ed58-40a6-8ea1-14a4fc1e38d7\",\"udi\":\"umb://element/75accad9c96c4e32a59f3b2daaa659ae\",\"umbracoNaviHide\":0}]}"
          }
       ],
       "settingsData":[
          {
             "contentTypeKey":"a2d6796c-c00c-4d8b-9839-dfdd2961dc9d",
             "udi":"umb://element/1623d9dee3f940e2973f1a7065abb41c",
             "BgColor":null,
             "umbracoNaviHide":0,
             "Padding":null,
             "Alignment":null,
             "SectionImage":"[]",
             "ImageOverlayColor":null
          }
       ]
    }
    

    If I un-encode the Col1Content, I get this:

    {
       "layout":{
          "Umbraco.BlockList":[
             {
                "contentUdi":"umb://element/3afcc0230fbb4dda956ec4413cac5551",
                "settingsUdi":"umb://element/75accad9c96c4e32a59f3b2daaa659ae"
             }
          ]
       },
       "contentData":[
          {
             "contentTypeKey":"9ed671c2-5298-4621-8844-158f3fcd6ca8",
             "udi":"umb://element/3afcc0230fbb4dda956ec4413cac5551",
             "BlockName":"My Custom Block name",
             "HeadingLevel":"h1",
             "Header":"My Header",
             "Subheader":null,
             "Alignment":null
          }
       ],
       "settingsData":[
          {
             "contentTypeKey":"57e2218c-ed58-40a6-8ea1-14a4fc1e38d7",
             "udi":"umb://element/75accad9c96c4e32a59f3b2daaa659ae",
             "umbracoNaviHide":0
          }
       ]
    }
    

    I've tried these as well:

    {{Col1Content[0].BlockName}}
    
    {{Col1Content[1].BlockName}}
    

    ...but nothing ever displays.

    Has anyone done something like this?

  • bh 414 posts 1401 karma points
    Mar 17, 2023 @ 14:42
    bh
    1

    @HeatherFloyd I've found this article super helpful: https://joe.gl/ombek/blog/umbraco-angularjs-filter-cheat-sheet/

  • Heather Floyd 605 posts 1006 karma points MVP 5x c-trib
    Mar 17, 2023 @ 16:57
    Heather Floyd
    101

    Thanks for that... seems I can look into this:

    Nesting block lists?

    Block lists within your block can be accessed by using the name of the block list property followed by contentData.

    e.g. Tab panel ({{ tabs.contentData.length }} tabs) becomes Tab panel (5 tabs)

    Since this is just an array, we can also take advantage of the umbCmsJoinArray filter here!

    Things: {{ things | umbCmsJoinArray:', ':'title' }} becomes Things: Thing 1, Thing 2, Cat (in hat)

  • Heather Floyd 605 posts 1006 karma points MVP 5x c-trib
    Jul 12, 2023 @ 22:18
    Heather Floyd
    1

    FYI for anyone looking to do a similar thing...

    The syntax to get a property value from only the first nested block item:

    {{BLOCKPROPERTY.contentData[0].CHILDPROPERTYALIAS}}
    

    ex:

    {{Col1Content.contentData[0].BlockName}}
    

    Sadly, I wasn't able to figure out how to get the calculated "label" for the nested items, which would make this more flexible.

  • fatmazayed 41 posts 122 karma points
    Nov 14, 2023 @ 20:56
    fatmazayed
    0

    i want to enable to select the child in block list

Please Sign in or register to post replies

Write your reply to:

Draft