Can you access multi url picker link properties in a block list or block grid item label in v16?

hey out there, we’re in the process of upgrading a v13 site to v16

we’ve run into a problem trying to convert this angular code that’s being used in a block list label:

{{link[0].nodeName || link[0].name ? link[0].name : link[0].url }} {{$settings.hide == '1' ? '(hidden)' : ''}}

the doctype property alias is link and it’s using the multi url picker datatype (in the use case, it has a max of 1 items so it’s effectively in single mode but we also have it in multi mode elsewhere in the site).

having found the post Block List Label from Multi Url Picker (Name not displaying) and our previous post How can you use a block list or block grid settings model property in a label in v16? we know we can do this:

{umbLink:link} ${$settings.hide ? '(hidden)' : ''}

which is working:

however we can’t seem to access the properties of the link? e.g if we add a link without a title:

we want to fallback to the url as no value comes out:

we’ve tried:

{umbLink:link.url}
{umbLink:link:url}
{umbLink:link[0].url}
{umbLink:link[0]:url}

interestingly, attempting the same but using umbValueresults in {object Object} being output:

{umbValue:link:url}

so far, no joy…

has anyone out there managed to do something like this?!?! would :heart: to hear from you if you have :wink:

1 Like

Hi @jakewilliamson

You can use in umbraco v16.2, support for Block Settings data has been added to UFM. Along with this, there is an advanced UFM syntax that can do JS-like expressions, (pretty much how AngularJS expressions worked).

{umbLink: links}

1 Like

The {umbLink} is a regular UFM function and is available in 16.1 and earlier.

The new, more advanced syntax available in 16.2 enables you to output raw values, which could be suitable for the post here:

${link[0].name ? link[0].name : link[0].url}

You have to prefix it with a $sign to “turn on” the advanced JS-like syntax.

2 Likes

absolutely amazing :high-5-you-rock:

thank you @deepakaggrawal and @jacob for the replies, i have a feeling that using the $ prefix to ‘turn on’ the advanced js-like syntax is going to be the winning answer for a lot of our label based questions :wink:

1 Like

Give it a try on the Release Candidate if you’d like:

https://our.umbraco.com/download/releases/1620

1 Like