Copy link to clipboard
Copied
Perhaps I’m overlooking something in the BC docs but I can’t find an answer for my question.
How can I filter web app items when a boolean web-app-item-field is checked (=true) in the back-end?
The web app itself is a listing-web-app. What I want to achieve is, that when the web-app-item-field is checked, that the web-app-item (and its web-app-item-fields) will be displayed on the web page.
The web page contains the code that references the web-app-item-fields
Hope you can me help with this.
Thanks,
Kind regards, Carla
Are you referring to rendering the page, using liquid, if the box is checked?
For Liquid rendering, you can do this:
{% if this.['My Boolean Field'] == '1' -%}
The boolean field is checked, show whatever fields or information is here.
{% else -%}
The Boolean field is not checked so you can show what you would like here.
{% endif -%}
If you don't want to show anything if it is not checked, then do this:
{% if this.['My Boolean Field'] == '1' -%}
Will only show if checked.
{% endif -%}
Copy link to clipboard
Copied
Are you referring to rendering the page, using liquid, if the box is checked?
For Liquid rendering, you can do this:
{% if this.['My Boolean Field'] == '1' -%}
The boolean field is checked, show whatever fields or information is here.
{% else -%}
The Boolean field is not checked so you can show what you would like here.
{% endif -%}
If you don't want to show anything if it is not checked, then do this:
{% if this.['My Boolean Field'] == '1' -%}
Will only show if checked.
{% endif -%}
Copy link to clipboard
Copied
Hi Lynda,
Thanks for your answer. I will try your solution if this will work in my case.
There is one slight problem with the if else statement I think that I've to place the same html-code on the web-page with the liquid-tags twice. The boolean field serves only to filter out a web-item. I.e. "house of the month". After "looping through" an other house (not equal to "house of the month") must be placed on the web-side.
Or should I place the html-code in a "content-holder"?
When filtering web-app-items, do you always have to use "if - else" or are there other solutions for this?
Thanks, Carla
Copy link to clipboard
Copied
I would ask why you need to filter based on that option.
You have two limitations with this.
1. 500 max limit of items
2. If you paginate then the filter only applies to each pagination set.
You have two actual filter options on web apps.
1. Enable option to disable or enable the items to stop them showing up
2. Classifications - You can classify the items to show up on the relevant module with classification calls and removing them from that classification stops them showing up.
Copy link to clipboard
Copied
Hi Liam,
You are right. I was more thinking in the client's perspective and make it as simple as possible. They only want to show it up in the home page. So a simple click for "on" "off" seemed to be easy. Disadvantage of course is, when they leave it on.
With adding the object (the house) to a classification will have the same disadvantage when they forget to edit it.
Would be nice if you could see it in the back-end right-away without clicking "categories" first.
How should I organise/code things when I want to show up the object with the "classification" and the latest items.
i.e "house of the month" and "latest added house"
Krgds Carla
Copy link to clipboard
Copied
For things like home page we always use classification. Classify as homepage. This then means you do not need the custom field or any of that liquid and html.
Copy link to clipboard
Copied
Hi Liam,
Sometimes the solution is much simpler then you think. Never thought about it.
Thanks again.