Conditional check not working against asset property with variations enabled

Russ

Well-known member
Affected version
2.2 Beta 6
In 2.2 I had a very simple conditional like this:

Code:
                    <xf:if is="property('xbFooterLogo')">
                        <a href="{{ ($xf.options.logoLink && $xf.homePageUrl) ? $xf.homePageUrl : link('index') }}">
                            <img src="{{ base_url(property('xbFooterLogo')) }}" alt="{$xf.options.boardTitle}" width="{{ property('footerLogoWidth') ?: '' }}" height="{{ property('footerLogoHeight') ?: '' }}" />
                        </a>
                    </xf:if>

It simply checked if this property had a logo:
1714509711108.webp

Worked fine.


The same conditional does not work with "Enable variations" on the property.


You can easily test it using the 2x logo URL (leave it blank)

Code:
<xf:if is="property('publicLogoUrl2x')">test</xf:if>

"test" will always show even though no images have been uploaded to the property.
 
The base value of properties with variations enabled is always a CSS variable, even if all of the values are blank. I'm not sure we'll be able to change this as our Less magic relies on it, but I'll see if we can come up with an alternative. You can also check the value of a specific variation using ie. property_variation('xbFooterLogo', 'default'), but perhaps that's not useful for this case.

As a side note, you'll want to use style_variation_macros::picture for variation images (which I'll need to fix to address the same underlying problem):

HTML:
<xf:macro id="style_variation_macros::picture"
    arg-property="xbFooterLogo"
    arg-width="{{ property('footerLogoWidth') }}"
    arg-height="{{ property('footerLogoHeight') }}"
    arg-alt="{$xf.options.boardTitle}" />
 
Back
Top Bottom