Solved "IsEmpty" not working with variable?
#1
I'm having an issue using a variable to control the visibility of my fanarts. It doesn't seem to work at all although the content of the variable seems correct. Maybe the problem is in the IsEmpty function?

What I didd first is creating a variable called MetaFanart (which at the moment only contains the standard fanart of the currently selected element):

xml:
<variable name="MetaFanart">
    <value condition="!String.IsEmpty(ListItem.Art(fanart))">$INFO[ListItem.Art(fanart)]</value>
    <value></value>
</variable>

Then, in the background of my layout I show a text label with the content of the variable as a check that everything works as it should (and it does).

xml:
<control type="label">
    <label>$VAR[MetaFanart]</label>
    <visible>true</visible>
</control>

So, the next step is to show the actual fanart but make it visible only when it exists, so...

xml:
<control type="image">
    <description>Fanart Image</description>
    <include>BackgroundDimensions</include>
    <texture>$VAR[MetaFanart]</texture>
    <visible>!String.IsEmpty($VAR[MetaFanart])</visible>
    <!--<visible>true</visible>-->
</control>

...and there is the proble, it doesn't work!? If I set the visible tag to true, it works with no problem. Is there any bug in the "String.IsEmpty" function or should I use something different for variables?

Regards and thanks in advance
Reply
#2
Solved, it's always the same, you strugle with something for a long time (not that much, just a couple of days) and inmediately after you ask for help, you finally find the solution. For completeness, I include it here, maybe it'll help somebody in the future.

Short answer: NO, String.IsEmpty doesn't work with variables.

...but there is a simple hack or workaround:

You have to create a dummy text label. It'll be invisible and it'll contain the text of the variable:

xml:

<control type="label" id="6661">
    <description>Dummy label to control the visibility of fanart image</description>
    <label>$VAR[MetaFanart]</label>
    <visible>false</visible>
</control>

Then, you control the visibility of your "real" control checking if the dummy control is empty or not:

xml:
<control type="image">
    <description>Fanart Image</description>
    <include>BackgroundDimensions</include>
    <texture>$VAR[MetaFanart]</texture>
    <visible>!String.IsEmpty(Control.GetLabel(6661))</visible>
</control>
Reply

Logout Mark Read Team Forum Stats Members Help
"IsEmpty" not working with variable?0