Block list label using UFM - Accessing nested prop...
# help-with-umbraco
k
Hi there! We've just upgraded to Umbraco 14.3 and I'm trying to figure out how to access nested properties of field values for block list items. I'm using a color picker and used to be able to access what I needed with {{ backgroundColor.label }} but since the upgrade, the farthest I could go is with {=backgroundColor} which displays "[object Object]" as the label ( {=backgroundColor.label} displays an empty comment propably because it doesn't exist or has a null value).
k
Unfortunately it appears this isn't yet possible with the UFM syntax, even still on the latest release (v15.1.1). Among many other issues in v14+, unless there's something I'm missing, it's not possible to access much of anything with UFM -- no sub or nested properties, no settings, etc.
k
Well - techincally I should think almost anything is possible if you write your own extension. I agree it's a bit limited out of the box right now, but you can do anything if you code it 😉 https://docs.umbraco.com/umbraco-cms/reference/umbraco-flavored-markdown
Copy code
json
{
  type: 'ufmComponent',
  alias: 'My.CustomUfmComponent',
  name: 'My Custom UFM Component',
  api: () => import('./components/my-custom.component.js'),
  meta: {
    alias: 'myCustom'
  }
}
Copy code
js
import { UmbUfmComponentBase } from '@umbraco-cms/backoffice/ufm';

export class MyCustomUfmComponentApi extends UmbUfmComponentBase {
  render(token: Tokens.Generic) {
    // You could do further regular expression/text processing here!
    return `<ufm-custom-component text="${token.text}"></ufm-custom-component>`;
  }
}

export { MyCustomUfmComponentApi as api };
k
Fair point. You're right -- while it's not as straightforward as writing a one-liner js expression directly in the block list label field, there is a way to do it with extensions/custom property editors.
k
Yeah, don't have that kind of time in front of me right now, to write those labels, but I'll try to get around to it (which will probably the time when it'll be native to the UFM X) Thanks for your inputs!
75 Views