Is there a way to set an elements style value based on a custom field value?
I have a loop which displays CPTs. Each CPT has a custom field for Status.
I want to set the background colour of the card depending on the Status of the CPT.
e.g. Green for Active, Red for Closed, Yellow for Pending.
I thought that either Conditions or Interactions might be able to do this, but doesnât appear so.
Thought that maybe I could set the Status field value to be a colour and then use that dynamic value in the style ⊠but it introduces other issues with users understanding! Users are always a problem. lol
If it is always the same red color, then I would just make a copy of that text element, change the text color to red and add a condition to that element that it only shows if the value of the acf checkbox field is true or false (I donât remember if it is 0 or 1),
Then add the opposite condition to the normal text element.
You can use the same method for the link element.
I have not worked a lot in Bricks lately so I get a bit rusty, sorry.
Itâs actually all of the text elements in the block (maybe 6 elements?). In principle I would rather not have duplicates of everything, hehe.
Worse, regarding the link, the link is the entire blockâŠ
Finally, I would like the block to have a different background color.
At this point it sounds more like we we are talking about two separate query loops, not conditions? That would not be ideal for sorting reasons (i.e., it would show all available items, then all unavailable itemsânot the worstâbut just kind of clunky).
I hope my use case makes sense. If unclear please let me know.
if you set the checkbox manually in each item (available or not) anyway, you could just add an acf color picker field in the fields for that post type and chose the red or green color for example in each post.
Then in the 6 elements, you can use the dynamic color function like this:
For the link, I have to think about a good way to do that. The easiest would be if the url is also coming from a url field in the post. Then you could just delete the url data in the post and the link will not do anything.