Hide item if not item in list iteration
So I have 2 lists of strings in 2 fields, altText and imagecaption. I wrapped them in a div. I want the divs not to be displayed if none of them were contained in some kind of loop, on each iteration of the loop. How can i do this?
30 = COA
30{
wrap = <div class="case-info">|</div>
required = 1
30 = TEXT
30{
wrap = <div>|</div>
field = altText
listNum.splitChar = 10
listNum.stdWrap.data = register:SPLIT_COUNT
required = 1
}
40 < .30
40.field = imagecaption
}
The result of the html:
<div class="case-info">
<div></div>
<div></div>
</div>
+3
source to share
1 answer
Remove the wrapper and try it like this:
30 = COA
30{
stdWrap.required = 1
stdWrap.wrap = <div class="case-info">|</div>
30 = TEXT
30{
field = altText
listNum.splitChar = 10
listNum.stdWrap.data = register:SPLIT_COUNT
trim = 1
required = 1
wrap = <div>|</div>
}
40 < .30
40.field = imagecaption
}
This way the wrapper will only execute if there is content (required = 1)
+2
source to share