I'm trying to get all entries that related to one .. three categories, as determined whether their id appears in the query string:
{% set sector = craft.categories.id(craft.request.getQuery('sector')) %}
{% set impact = craft.categories.id(craft.request.getQuery('impact')) %}
{% set topic = craft.categories.id(craft.request.getQuery('topic')) %}
{% for post in craft.entries.section(section).relatedTo('and', sector, impact, topic) %}
This works well if each of sector, impact, and topic are present, but will return nothing if any one of sector, impact, topic is null (i.e. getQuery('') is blank). Can anyone suggest a way I can do this?