I created a variant in SXA with a NVelocit template. In this variant I am displaying some text in an a tag: <a href="$item.Fields.Link" target="_blank">Test</a>
This works fine, but when my field "Link" is empty I don't want to show anything. So I found some information on NVelocity (not related to Sitecore though) that showed I could do this:
#if ($item.Fields.Link != "")
<a href="$item.Fields.Link" target="_blank">Test</a>
#end
I also tried with single quotes, with .empty
, .. but nothing seems to work. I get no output anymore when doing this. If I put something after my end (just to test), that text is still shown. My field is very empty (no space or so).
Is there a way to use some NVelocity coding in SXA?
ps: I found this blog from Michael https://michaellwest.blogspot.com/2018/02/access-reference-fields-in-sxa.html where he uses #set
so I guess something should be possible...
Using SXA 1.7