Block List Label with multiple angular filters
# help-with-umbraco
s
I have this block list where I want to make a label whether a specific property is available. If the header property is there I do this:
{{header != null ? header : null | ncRichText | truncate:true:50 }}
If the link property is there I do this:
{{link != null ? link : null | ncNodeName | truncate:true:50 }}
But how do I combine these so I don't get text from both the
header
and the
link
? https://cdn.discordapp.com/attachments/1308158732827361451/1308158733595185213/image.png?ex=673ced42&is=673b9bc2&hm=220f87f257e6a3de91dea4bd4508be5ac3bd57d5d40f49505e468490f39877f4& https://cdn.discordapp.com/attachments/1308158732827361451/1308158734379515945/image.png?ex=673ced42&is=673b9bc2&hm=838f4cdc9301c8c2a603ab79f0eb6f9efca0e052b5db4d6dede589f3ba0f136c&
l
Does a multi-level check work? {{header != null ? header : link != null ? link : null | ncRichText | truncate:true:50 }}
m
Also there is the option to create your own filter... 😉 Prob with this as the starting point https://github.com/umbraco/Umbraco-CMS/blob/release-13.5.2/src/Umbraco.Web.UI.Client/src/common/filters/nestedcontent.filter.js But also plenty of inspiration from the other filters too.. https://github.com/umbraco/Umbraco-CMS/tree/release-13.5.2/src/Umbraco.Web.UI.Client/src/common/filters
s
@Lamont Well, since
link
is an UDI you can't use
ncRichText
to get the name of the document, and that is my problem.
s
You can add all then {{ }} blocks you need, so you could do like {{header != null ? header : null | ncRichText | truncate:true:50 }}{{header == null && link != null ? link : null | ncNodeName | truncate:true:50 }} this would display the header if its not null or the link if the header is null and the link is not
l
Oh derp, yeah sorry. end of day dead brain there on the ncNodeName. I'd assumed you'd already tried it like skttl's and then didn't think any futher haha
d
I've used ternary operators to show if a page is published as well:
Copy code
{{$settings.wFtSetPropPublished == '0' ? '🚫 ' : "🟢 "}}{{$contentTypeName}}{{wFtPropTitle ? ' - ' + wFtPropTitle : ''}}
s
@skttl : Yeah, but apparently
header
can be both '' and null, so now I'm rolling with this 🙂
{{(link == null || link == '') && header != null ? header : null | ncRichText | truncate:true:50 }}{{(header == null || header == '') && link != null ? link : null | ncNodeName | truncate:true:50 }}
Thanks for all your suggestions
10 Views