Skip to content

Conversation

@amici-infotech
Copy link

Forked Changes

  • Added support for Craft Commerce product types alongside standard entry types
  • Improved type handling to work with multiple entry/product types simultaneously
  • Added support for passing entry type handles as:
    • Single string: 'events'
    • Array of strings: ['events', 'conferences']
  • Added support for passing entry type objects directly:
    • Single object: craft.app.entries.getEntryTypeByHandle('events')
    • Array of objects: [craft.app.entries.getEntryTypeByHandle('events'), craft.commerce.productTypes.getProductTypeByHandle('conferences')]
  • Priority given to Craft entries over Commerce products when type handles are the same

Examples:

{# Single type #}
{% set entries = craft.entries.section('events').isFuture('dateFieldHandle', 'events') %}

{# Multiple types with array #}
{% set entries = craft.entries.section(['events', 'conferences']).isFuture('dateFieldHandle', ['events', 'conferences']) %}

{# Using entry type objects directly #}
{% set eventType = craft.app.entries.getEntryTypeByHandle('events') %}
{% set entries = craft.entries.section('events').isFuture('dateFieldHandle', eventType) %}

{# Using multiple type objects from products #}
{% set types = [
  craft.commerce.productTypes.getProductTypeByHandle('events')
  craft.commerce.productTypes.getProductTypeByHandle('conferences')
] %}
{% set entries = craft.products().type(['events', 'conference']).isFuture('dateFieldHandle', types) %}

{# Using multiple type objects from entries #}
{% set types = [
  craft.app.entries.getEntryTypeByHandle('events'),
  craft.app.entries.getEntryTypeByHandle('conferences'),
] %}
{% set entries = craft.entries.section(['events', 'conferences']).isFuture('dateFieldHandle', types) %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant