Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
I'm using

Code: Select all
<cms:if "<cms:not_empty my_field />" > 

do something..

</cms:if>

<cms:if "<cms:not_empty my_other_field />" >

do something..

</cms:if>


How can i check if two fields are both not empty and do something?

Is there a way to use AND with <cms:if ?
We can use the && operator: https://docs.couchcms.com/tags-reference/if.html

Just be sure to wrap each <cms:not_empty /> tag with quotes inside the parentheses:

Code: Select all
<cms:if (“<cms:not_empty my_field />” && “<cms:not_empty my_other_field />”)>
  Neither are empty
</cms:if>


Or set variables ahead of time:

Code: Select all
<cms:set not_empty_my_field = "<cms:not_empty my_field />" />
<cms:set not_empty_my_other_field = "<cms:not_empty my_other_field />" />

<cms:if (not_empty_my_field && not_empty_my_other_field)>
  Neither are empty
</cms:if>
Perfect! That solved it
Thank you for your answer. Much appreciated!
3 posts Page 1 of 1
cron