I'm using a Matrix Field to display lists of entries. One extracts entries based on certain categories. They may or may not be set, but I need to use an "and" relatedTo parameter. At the moment it uses the default "or" option. Any suggestions on how I can be smarter about this?

The Code is currently as such:

{% set country = block.countryCategory %}
{% set location = block.locationCategory %}
{% set person = block.personCategory %}
{% set role = block.roleCategory %}

{% set categories = craft.categories.group(block.category).relatedTo(country, location, person, role).find() %}


Browse other questions tagged or ask your own question.