I am using Bricks 1.9.6.1 and the latest Metabox version. I’ve setup a condition that uses {query_results_count:queryid} that is several metabox groups deep but I can’t seem to get it working.
I am using Metabox and have a CPT setup with custom fields. Within the custom fields I have several groups within groups which requires me to have multiple queries setup in the structure to get the data I want.
The data displays correctly but the condition is not working on the list that is checking the query on the list item.
Basically I want the whole list to disappear (ie the ul tags) if there are no list items.
I am wondering if query_results_count is having issues because the metabox field group is 3 levels deep?
I’ve tripled checked the query id and it is correct (the list item id).
If not, could you send temporary login credentials and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase?
I tried your condition idea and it didn’t work either.
I did try the 2 other queries on the page and they return a count (with one of them being the parent group of the list item group) and they worked. List Item shows a 0 though (instead of 2)
Also within the List Item query i can use just {query_results_count} without the id and it returns 2 which is the correct result but obviously doesn’t help me here since I want to disable the list if no list items.
I will send the login details to the website via support.
I stumbled upon this thread when looking for a solution to having loops more than 1 level deep and still using conditions to hide their parent containers.
Could someone explain to me the loop depth in a bit more context? I don’t quite understand in this thread, or in the official docs: " {query_results_count:quer34} only works if the target query is 1 level deep. You wouldn’t be able to get the correct count if the target query located in a >= 2 level deep nested query."
In case it helps another searcher - I wound up using a CSS approach which is a little hackier but works well if you don’t mind the container continuing to appear in the DOM, albeit hidden.
Assign the child block (with your levels-deep query loop) a class like monitored-block.
Assign the parent container/whatever a class like conditional-container.
Set up a Bricks condition on the child block using whatever method, I used query_results_count so the block is hidden if no loop contents.
Leverage that block disappearing to also hide the parent container with some CSS on the container’s Style tab:
The code snippet initiates a query to get the results count for the Metabox group “safety_rules_section” and subfield “list” which in my Metabox setup are a group of custom fields.