Answers.Body: <p>For most cases you can find a workaround to combine such conditions by making use of entry IDs.</p>
  
  <p>In this example query for each time range condition separately and use the <code>ids()</code> method to "collect" your entries. All matching IDs are then passed to the <code>id</code> parameter of a final ElementCriteriaModel, that you can also use for Pagination etc.:</p>
  
  <pre><code>{% set dateParamCw32 = 'and, &gt;= 2014-08-04 00:00:00, &lt; 2014-08-10 23:59:59' %}
  {% set dateParamCw34 = 'and, &gt;= 2014-08-18 00:00:00, &lt; 2014-08-24 23:59:59' %}
  
  {% set entriesCw32Ids = craft.entries.section('events').startDate(dateParamCw32).ids() %}
  {% set entriesCw34Ids = craft.entries.section('events').startDate(dateParamCw34).ids() %}
  
  {% set idParam = [] %}
  {% set idParam = idParam|merge(entriesCw32Ids) %}
  {% set idParam = idParam|merge(entriesCw34Ids) %}
  
  {% set entries = craft.entries.id(idParam) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-05T10:11:22.653Z
Answers.LastActivityDate: 2017-06-29T10:24:44.983Z
Answers.LastEditDate: 2017-06-29T10:24:44.983Z
Answers.UserDisplayName: carlcs
Body: <p>How would you combine multiple logical expressions on a ElementCriteriaModel parameter?
  You could query twice and then merge the two returned arrays of entry models,
  but that probably wouldn't allow me to later use the <a href="http://buildwithcraft.com/docs/templating/paginate" rel="nofollow"><code>{% paginate %}</code></a> tag or methods like <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNext" rel="nofollow"><code>getNext()</code></a>.</p>
  
  <p>Here's an example where I'd like to filter events starting in calender week 32 or 34:</p>
  
  <pre><code>{% set dateParamCw32 = 'and, &gt;= 2014-08-04 00:00:00, &lt; 2014-08-10 23:59:59' %}
  {% set dateParamCw34 = 'and, &gt;= 2014-08-18 00:00:00, &lt; 2014-08-24 23:59:59' %}
  
  {% set startDateParam = 'date range cw32 OR cw34' %}
  
  {% set entries = craft.entries.section('events').startDate(startDateParam) %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-05T15:04:50.347Z
Comments.Text: This is a complicated answer and would need to be answered by Pixel & Tonic. Each condition goes through Craft's condition processor and then through Yii's condition processor before finalizing as a query. There's a lot of moving parts, and they would know those parts.
Comments.UserDisplayName: Bryan Redeagle
Tags: <elementcriteriamodel>
Title: Complex logic on a ElementCriteriaModel parameter?
ThreadText: # Complex logic on a ElementCriteriaModel parameter?
  
  (Asked by: username_0 on 2014-08-15)
  
  How would you combine multiple logical expressions on a ElementCriteriaModel parameter?
  You could query twice and then merge the two returned arrays of entry models,
  but that probably wouldn't allow me to later use the [`{% paginate %}`](http://buildwithcraft.com/docs/templating/paginate) tag or methods like [`getNext()`](http://buildwithcraft.com/docs/templating/entrymodel#getNext).
  
  Here's an example where I'd like to filter events starting in calender week 32 or 34:
  
  ```
  {% set dateParamCw32 = 'and, >= 2014-08-04 00:00:00, < 2014-08-10 23:59:59' %}
  {% set dateParamCw34 = 'and, >= 2014-08-18 00:00:00, < 2014-08-24 23:59:59' %}
  
  {% set startDateParam = 'date range cw32 OR cw34' %}
  
  {% set entries = craft.entries.section('events').startDate(startDateParam) %}
  
  ```
  
  **Tags:** elementcriteriamodel
  
  > **Comments:**
  > **username_1**: This is a complicated answer and would need to be answered by Pixel & Tonic. Each condition goes through Craft's condition processor and then through Yii's condition processor before finalizing as a query. There's a lot of moving parts, and they would know those parts.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-11-05. Score: 9 | Accepted answer
  
  For most cases you can find a workaround to combine such conditions by making use of entry IDs.
  
  In this example query for each time range condition separately and use the `ids()` method to "collect" your entries. All matching IDs are then passed to the `id` parameter of a final ElementCriteriaModel, that you can also use for Pagination etc.:
  
  ```
  {% set dateParamCw32 = 'and, >= 2014-08-04 00:00:00, < 2014-08-10 23:59:59' %}
  {% set dateParamCw34 = 'and, >= 2014-08-18 00:00:00, < 2014-08-24 23:59:59' %}
  
  {% set entriesCw32Ids = craft.entries.section('events').startDate(dateParamCw32).ids() %}
  {% set entriesCw34Ids = craft.entries.section('events').startDate(dateParamCw34).ids() %}
  
  {% set idParam = [] %}
  {% set idParam = idParam|merge(entriesCw32Ids) %}
  {% set idParam = idParam|merge(entriesCw34Ids) %}
  
  {% set entries = craft.entries.id(idParam) %}
  
  ```
  
  
  ---
  
  