how to add a link to the custom badges module to check if there is a link or not before rendering the image?
There are some award badges on our website that we would like to add the links to their respective pages. This is the question that the web developer helping us is stuck on.
to get it right - you’d like to check if there is a link and if so link the image - otherwise show just the unlinked image, right?
If so you can do it like this:
{% set link = module.link.href %}
{% if link != "" %}{# layout if the link is not(!) empty #}
<a href="{{ link }}">
<img src="{{ module.image.src }}">
</a>
{% else %} {# layout if the link is empty #}
<img src="{{ module.image.src }}">
{% endif%}
If you provide the whole code we can provide more precise guidiance