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?
'and'somewhere in thecategoriesvalue? – Lindsey D Sep 25 '14 at 05:11.relatedTo('and', categories)it performs an "or" query, rather than an "and". Any ideas? – Daniel Sep 25 '14 at 14:03{% set categoriesIds = craft.categories.id(ids).ids() %}? – Jamie Pittock Sep 26 '14 at 12:25