XF 2.1 Conditional Statements in less

Yodrak

in memoriam 1976 - 2020
I have made an addon where shows images in polls. Now i want to show the images in 2 columns.
If i change

HTML:
.inputChoices
{  
    list-style: none;
    padding: 0;
    margin: 0;
}

to

Code:
.inputChoices
{
<xf:if is="$template =='yip_poll_macros'">
    column-count: 2;
    </xf:if>
    list-style: none;
    padding 0;
    margin 0;
    }

Then the Image Poll look like this:
192132

And every template with input_choices in it look like this:

192133


So how can i fix this issue?
 
You should break down the less to the polls. Just inputChoices works with every input choice.
Take a look at the poll template and search for more class values.
 
In short, you don't do that in LESS/CSS. You define overrides via additional classes and then opt-in to that behavior in the HTML by adding the class (conditionally, if needed).
 
In short, you don't do that in LESS/CSS. You define overrides via additional classes and then opt-in to that behavior in the HTML by adding the class (conditionally, if needed).
Looks like core_reaction.less uses conditions (XF 2.1.9):

1589624519880.webp
 
Looks like core_reaction.less uses conditions (XF 2.1.9):

Conditions work just fine in templates. Mike also never said you shouldn't use them. The specific use case from the first post doesn't work, because the css templater doesn't have any context about the page it is rendering.
 
Back
Top Bottom