Skip to main content
Deleted old / wrong code
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}

{# Merge queried Ids #}
{% set filteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set filteredEntries = craft.entries.id(filteredIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
    {# Set conditionals to filter for desired entries #}
    {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

        {# Merge entries #}
        {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
    {% endif %}
  
{% endfor %}
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}

{# Merge queried Ids #}
{% set filteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set filteredEntries = craft.entries.id(filteredIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
    {# Set conditionals to filter for desired entries #}
    {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

        {# Merge entries #}
        {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
    {% endif %}
  
{% endfor %}

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}

{# Merge queried Ids #}
{% set filteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set filteredEntries = craft.entries.id(filteredIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
    {# Set conditionals to filter for desired entries #}
    {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

        {# Merge entries #}
        {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
    {% endif %}
  
{% endfor %}
improved formatting
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %} 

{# Merge queried Ids #}
{% set allIdsfilteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set allEntriesfilteredEntries = craft.entries.id(allIdsfilteredIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
      {# Set conditionals to filter for desired entries #}
      {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

            {# Merge entries #}
            {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
      {% endif %}
  
{% endfor %}
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set allIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set allEntries = craft.entries.id(allIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
      {# Set conditionals to filter for desired entries #}
      {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

            {# Merge entries #}
            {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
      {% endif %}
  
{% endfor %}
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %} 

{# Merge queried Ids #}
{% set filteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set filteredEntries = craft.entries.id(filteredIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
    {# Set conditionals to filter for desired entries #}
    {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

        {# Merge entries #}
        {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
    {% endif %}
  
{% endfor %}
Added additional approach / code correction
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries andto get the Ids of the desired entries, merge the resultsIds and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set entriesStartDatestartDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set entriesEndDateendDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set allIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set allEntries = entriesStartDatecraft.entries.id(allIds) |%}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# mergeGet all potential entries #}
{% set allEntries = craft.entries.section(entriesEndDate'events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
      {# Set conditionals to filter for desired entries #}
      {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

            {# Merge entries #}
            {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
      {% endif %}
  
{% endfor %}

You could do two queries and merge the results:

{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}
You could do two queries and [merge][1] the results:
{% set entriesStartDate = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}
{% set entriesEndDate = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends) %}

{% set allEntries = entriesStartDate | merge(entriesEndDate) %}

Edit:

You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '>= ' ~ unixbegins, '< ' ~ unixends).ids() %}
{% set allIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set allEntries = craft.entries.id(allIds) %}

.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}
  
      {# Set conditionals to filter for desired entries #}
      {% if ( entry.startDate >= unixbegins and entry.startDate < unixends ) and ( entry.endDate >= unixbegins and entry.endDate < unixends ) %}

            {# Merge entries #}
            {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
      {% endif %}
  
{% endfor %}
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140
Loading