Multiple If conditions for different subjects?

I have the following:

[[*buttontitle]] and [[*buttonlink]]

I want to output this only if both of these are notempty: I can do the following for 1 of these:

[[!If?
&subject=`[[*buttontitle]]`
&operator=`notempty`
&then=`output button here`]]

But how do I do this to check both of these to ensure it doesn’t output unless both are not empty? Sorry if this is a dumb question. Still getting my feet wet on this and can’t find this in the documentation anywhere. This seems like it should be fairly simple, perhaps have multiple subjects to check? Is that even possible? The documentation on the if condition does not provide a way to check multiple subjects: If - If | MODX Documentation so I’m guessing it’s not possible to do such a simple thing?

Maybe you can use this:

[[*buttontitle:notempty=`[[*buttonlink:notempty=`output button here`]]`]]

or this:

[[*buttontitle:isnot=``:and:if=`[[*buttonlink]]`:isnot=``:then=`output button here`]]

But sometimes it’s just easier to write a snippet for more complex conditions.

1 Like

Thank you! It’s just a basic and condition. Wasn’t aware that you can nest them like so. Very Cool though.

maybe this could be usefull for cases like that:

AndIf snippet for MODX. Extended version of the ‘If’ snippet. (github.com)