Problem getting IF extra to toggle a class via a Checkbox tv

I’m trying to get a class to toggle on a list-item via a simple checkbox utility using a TV and an IF extra statement. I initially referred this forum post.

In the 1st instance I’ve written 2 classes, one for when the checkbox is selected, and another for the else/default fallback condition - this was to test if it was partially working.

Currently the fallback class is all that shows so I guess that means the IF partially works. Ideally I only want to toggle one class for when the checkbox is selected as it doesn’t actually need a fallback.

Here’s the TV details:

Type: Check Box
Input Option Values: Keyline==1
Default Value: Keyline==0

The TV shows in the content editor, I can select it on/off no problem.

I’ve tried variations on this TV to get it working e.g.: Input Values as only integer 0/1, Input Values empty (no checkbox showed).
These have all been reflected in the IF statement but I always get the same result - only the default fallback class renders in the markup.

I’ve integrated the IF statement on an <li> element - have tried it cached/uncached and with the TV using * or +

<li class="splide__slide 

On the frontend it only renders the following irrespective of variations/tests:

<li class="splide__slide keyline-off" ... />

I really need the class keyline-on to render when the checkbox TV is selected in the content editor.

I’m sure this is just something simple that I’ve missed but can’t snag it.

Any help would be appreciated, thanks in advance.

I suppose the operand should be 1 instead of Keyline==1 in your IF statement.


Thanks but makes no difference and that was one of the options already tried.

Still getting:

<li class="splide__slide keyline-off" ... />

If you just put [[*tv_keylineClass]] directly in your template without the IF-snippet, what value gets outputted?

Interesting angle but still the same type of response:

<li class="splide__slide Keyline==0"/>

This is on all the list items - some with the checkbox ‘checked’, some without. All the same

Have you tried changing the ‘Default Value’ of your TV?
Maybe leave it empty or just put in the value 0.

I think the default value should just be empty. That syntax for inputs in checkbox and radio TVs is Label==Value, so the values 0 and 1 shouldn’t have the same label of “Keyline”.

I’ve used conditionals for this use. Try this:


Thanks all -
@halftrainedharry yes I had tried that but no joy.
@lucy I’ve tried that and variations on that angle including the following:


Without the :else condition it’s just an empty space, and re-adding it leads to the same old default class of keyline-off

Bit of a tricky one!

Do you use getResources to output this list?
If that is the case, then did you set the property &includeTVs to 1. And what is the value of the property &tvPrefix? If the property &tvPrefix is not set then try



I’d completely forgotten about the getResources aspect of this, which I am using. I’ve not set &tvPrefix and left out the +tv. bit so rolled that in and it’s working perfectly. Also omitted the else condition and it’s working exactly as I want, no need for a fallback class.

So here’s the working version:

Type: Checkbox
Input Option Values: Keyline==1
Default Value: blank
<li class="splide__slide [[!if? &subject=`[[+tv.tv_keylineClass]]` &operator=`EQ` &operand=`1` &then=`keyline-on`]]">

With the checkbox selected this renders:

<li class="splide__slide keyline-on" ... />

otherwise it’s:

<li class="splide__slide " ... />

Job done.

@halftrainedharry and @lucy
Many thanks to you both! :grinning: :vulcan_salute:

1 Like