if / or statement

SOLVE
ben-duchy
Top Contributor

Does anyone know if it's possible to create an if statement that covers multiple options for the page editior?

 

I have a created a tabbed module to be reused for our various homes to show floorplans and dimensions which are displayed within the relevant tab (first floor, second floor, third floor) .

 

Depending on the house type selected, 1, 2 or 3 tabs will show. I will then target that specific house name selection to pull in the correct data within each tab.

 

For example

{% if module.house_name =='Bodnant','Oakfield','Stratford' %}

    3 tabs displayed to represent each floor of a 3 storey - selected house name data displayed within each tab

{% elif module.house_name =='Wentworth','Thornbury','Windsor' %}

    2 tabs displayed to represent each floor of a 2 storey - selected house name data displayed within each tab

{% else %}

    1 tabs displayed to represent bungalow - selected house name data displayed within sole tab

{% endif %}

 

Unfortunately this doesnt work. Is there a workaround? Ideally I dont want to have multiple if statements to cover every house name.

0 Upvotes
1 Accepted solution

Accepted Solutions
Kevin-C
Solution
Recognized Expert | Partner

Hey @ben-duchy 

 

You'll want to use the logical OR operator.

{% if module.house_name =='Bodnant' or module.house_name =='Oakfield' or module.house_name =='Stratford' %}

    3 tabs displayed to represent each floor of a 3 storey - selected house name data displayed within each tab

{% elif module.house_name =='Wentworth' or module.house_name =='Thornbury' or module.house_name =='Windsor' %}

    2 tabs displayed to represent each floor of a 2 storey - selected house name data displayed within each tab

{% else %}

    1 tabs displayed to represent bungalow - selected house name data displayed within sole tab

{% endif %}

 

View solution in original post

2 Replies 2
Kevin-C
Solution
Recognized Expert | Partner

Hey @ben-duchy 

 

You'll want to use the logical OR operator.

{% if module.house_name =='Bodnant' or module.house_name =='Oakfield' or module.house_name =='Stratford' %}

    3 tabs displayed to represent each floor of a 3 storey - selected house name data displayed within each tab

{% elif module.house_name =='Wentworth' or module.house_name =='Thornbury' or module.house_name =='Windsor' %}

    2 tabs displayed to represent each floor of a 2 storey - selected house name data displayed within each tab

{% else %}

    1 tabs displayed to represent bungalow - selected house name data displayed within sole tab

{% endif %}

 

View solution in original post

ben-duchy
Top Contributor

That's Perfect @Kevin-C  just what I needed. Thanks 😀