Reputation: 1
What's the opposite of ?has_content in CSS when checking whether a field has a value or not?
I'm trying to do an if-else logic and I have two fields, FieldA and FieldB. If FieldA has content, display FieldA, else dispaly FieldB.
Thanks.
Upvotes: 0
Views: 39
Reputation: 1
Thanks for the help jnylen. I instead used the <#if> <#else> clause as it is simpler to understand and maintain.
Upvotes: 0
Reputation: 13344
You can use :empty
for this, but this can only work in CSS if FieldA
comes right before FieldB
(or a couple of other relationships, but this is the easiest one to understand).
.FieldA + .FieldB {
display: none;
}
.FieldA:empty + .FieldB {
display: block;
}
Since this is application logic, and it depends on a specific relationship between these elements, it's probably better to do this in your application code instead (don't print FieldB
at all if it is not meant to be shown).
Upvotes: 1