Problem with logical order

Hi,

I’ve an issue regarding logical order, I mean I’d like to assign a variable true or false later in the code, then calling it upper:

{% if presents == 'true' %}Display text{% endif %}

{% assign presents_count = managers_count-absents_count %} {% if presents_count > 1 %}{% assign presents = true %}{% endif %}

The fact is that doesn’t work because the condition if presents is true is before.
Tried to capture also, didn’t work.

Thanks in advance !

Hello Axel,

As you’ve already mentioned the issue is in your order. Why don’t you try to change the order? For example:

{% assign presents_count = managers_count-absents_count %}

{% if presents_count > 1 %}{% assign presents = true %}{% endif %}

{% if presents == 'true' %}Display text{% endif %}

I think, this is going to work.

Regards,
Michail

Because it’s the same with absents_count:

{% for manager in period.directors %}{% unless manager.custom.box == 'true' %}{% assign absents = true %}{% assign absents_count = absents_count | plus:1 %}
{% unless manager.custom.civility == 'Société' %}{{manager.custom.civility}} {% endunless %}{{manager.name}} est {% if manager.custom.civility == 'Monsieur' %}absent et excusé{% else %}absente et excusée{% endif %}.{% endunless %}{% endfor %}

{% assign managers_count = period.directors.count %}
{% assign presents_count = managers_count-absents_count %}

I can’t put it upper because the assign must be after the first part of the code.

You are not using the managers_count-absents_count before right? If you are going to use it like that:

{% for manager in period.directors %}{% unless manager.custom.box == 'true' %}{% assign absents = true %}{% assign absents_count = absents_count | plus:1 %}
{% unless manager.custom.civility == 'Société' %}{{manager.custom.civility}} {% endunless %}{{manager.name}} est {% if manager.custom.civility == 'Monsieur' %}absent et excusé{% else %}absente et excusée{% endif %}.{% endunless %}{% endfor %}

{% assign managers_count = period.directors.count %}
{% assign presents_count = managers_count-absents_count %}

{% if presents_count > 1 %}{% assign presents = true %}{% endif %}

{% if presents == 'true' %}Display text{% endif %}

It will not work? You can also write :

{% if presents_count > 1 %}Display text{% endif %}

instead of:

{% if presents_count > 1 %}{% assign presents = true %}{% endif %}

{% if presents == 'true' %}Display text{% endif %}

I believe is the same thing.

No, because {% if presents == ‘true’ %}Display text{% endif %} might be, for exemple, the first line of the code, absolutely.

I just remembered that I had something similar that worked:

... et comme {% if period.custom.standard_ag.scrutineers.count == 0 %}scrutateur{% else %}scrutateurs{% endif %} {% input period.custom.standard_ag.scrutineer.civility as:select options:'Monsieur|Madame|Mademoiselle' %} {% input period.custom.standard_ag.scrutineer.name as:string placeholder:'<nom>' %}{% fori scrutineer in period.custom.scrutineers %}, {% input scrutineer.civility as:select options:'Monsieur|Madame|Mademoiselle' %} {% input scrutineer.name as:string placeholder:'<nom>' %}{% endfori %}

And now it doesn’t work anymore, like if you changed something in your language.

I just checked the code you provided and it seems to work fine. It just adds one more option when you choose the title you want. Or you don’t want it to do so? Can you please be more specific?