v18 conditional variable doesn't seem to work correctly for ListItem.Year
#1
=12ptHi there,

I am new to skinning but am having some success, today i ran into an issue using a variable with conditions. I wanted to display the ListItem.Year with a bracket either side if ListItem.Year is not empty. But for some reason I get the brackets with no characters between (so ListItem.Year appears empty). I have found a different way to make it work but am wondering why it didn't work. I thought I'd ask the question as I don't know if it's just me doing something stupid or if it's not supported or a bug.

I am running kodi v18 beta 3 compiled on 25/9/18 on a mac.
=12pt 

this works 
$INFO[ListItem.Label]$INFO[ListItem.Year, (,)]

this doesn't

variables.xml......................
<variable name="varYear">
        <value condition="String.IsEmpty.($INFO[ListItem.Year])"></value>
        <value> ($INFO[ListItem.Year])</value>
    </variable>


home.xml...................................
<control type="textbox">
.                 
.
                    <label>$INFO[ListItem.Label]$VAR[varYear]</label>
                   
                </control>


Is it just me??  Thanks in advance for any guidance.
Reply
#2
String.isEmpty() already expects an infolabel, so $INFO is not necessary:
 
Code:
        <value condition="String.IsEmpty(ListItem.Year)"></value>
Reply
#3
cheers for the response bkury, but now I have a different issue.

I just tried removing the $INFO tag and now it shows nothing even when there is a year string.

So now i have this 

<variable name="varYear">
        <value condition="String.IsEmpty.(ListItem.Year)"></value>
        <value> ($INFO[ListItem.Year])</value>
    </variable>
.
.
.
.
  <label>$INFO[ListItem.Label]$INFO[ListItem.Year, (,)]$VAR[varYear]</label>

and I have just placed the variable after the existing code so I can see double check whether year is empty or not, and now the variable never shows anything

any ideas?
Reply
#4
remove the dot after IsEmpty.

it's String.IsEmpty() not String.IsEmpty.()
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
I'm not 100% sure but I think you want to do something like this:
(usually you don't want to combine $INFO and $VAR in a <label>, instead you should handle every condition within the variable)
 
Code:
<variable name="Var_MyTextbox">
   <value condition="String.isEmpty(ListItem.Year)">$INFO[ListItem.Label]</value> <!-- show only the label if there is no year info available -->
   <value condition="!String.isEmpty(ListItem.Year)">$INFO[ListItem.Label] ($INFO[ListItem.Year])</value> <!-- show label and (year) if it's available -->
</variable>

<control type="textbox">
   <label>$VAR[Var_MyTextbox]</label>
   ...
</control>

edit: and try to use the code/syntax feature when posting skin code, it's much easier to spot a typo or syntax error
Reply
#6
Use simple code, no need to use variable !
If year is missing label for brackets and year will be emty.
Code:
<control type="textbox">
   <label>$INFO[ListItem.Label] $INFO[ListItem.Year,(,)]</label>
   ...
</control>
XBoxMediaCenter (Kodi Matrix ) 19.3 , AndroidBox -Matrix Skin AeonMQ6
Reply
#7
Awesome, I knew it had to be something I messed up.

thanks for the info regarding not combining $INFO and $VAR in a label, i will keep that in mind.

Cheers
Reply
#8
Thanks Angelinas,

I did end up using that code.  I found it during my search to work out why I couldn't get the variable to behave. It is much simpler for sure.
Reply

Logout Mark Read Team Forum Stats Members Help
conditional variable doesn't seem to work correctly for ListItem.Year0