Skip to main content
added 183 characters in body
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

To separate the categories, I'd set up multiple category groups, one for each of your entry types.

For example:

{% set categoryParams = {
    group: 'audioCategories',
    slug: 'podcasts'
} %}

{% set category = craft.categories(categoryParams).first() %}
{% set searchTerm = 'basketball OR soccer' %}

{% set entryParams = {
    section: 'news',
    type: 'audio',
    relatedTo: category,
    search: searchTerm
} %}

{% for entry in craft.entries(entryParams) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

.

This would list all theonly those entries which are

  1. in a sectionsection named "news"
  2. given an entry typeentry type (and entry template) "audio"
  3. related to a category from the category groupcategory group "audioCategories" (I queryadditionally filter for just a singlethe one cat. named "podcasts" to keep it simplethe example a little simpler)
  4. matching to the search termsearch term "basketball OR soccer"

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

For example:

{% set categoryParams = {
    group: 'audioCategories',
    slug: 'podcasts'
} %}

{% set category = craft.categories(categoryParams).first() %}
{% set searchTerm = 'basketball OR soccer' %}

{% set entryParams = {
    section: 'news',
    type: 'audio',
    relatedTo: category,
    search: searchTerm
} %}

{% for entry in craft.entries(entryParams) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

.

This would list all the entries which are

  1. in a section named "news"
  2. given an entry type (and entry template) "audio"
  3. related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
  4. matching to the search term "basketball OR soccer"

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

To separate the categories, I'd set up multiple category groups, one for each of your entry types.

For example:

{% set categoryParams = {
    group: 'audioCategories',
    slug: 'podcasts'
} %}

{% set category = craft.categories(categoryParams).first() %}
{% set searchTerm = 'basketball OR soccer' %}

{% set entryParams = {
    section: 'news',
    type: 'audio',
    relatedTo: category,
    search: searchTerm
} %}

{% for entry in craft.entries(entryParams) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

This would list only those entries which are

  1. in a section named "news"
  2. given an entry type (and entry template) "audio"
  3. related to a category from the category group "audioCategories" (I additionally filter for just the one cat. named "podcasts" to keep the example a little simpler)
  4. matching to the search term "basketball OR soccer"
added 183 characters in body
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

For example:

{% set categoryParams = {
    group: 'audioCategories',
    slug: 'podcasts'
} %}

{% set category = craft.categories.group('audioCategories').slug('podcasts'categoryParams).first() %}
{% set searchsearchTerm = 'basketball OR soccer' %}

{% forset entryentryParams in= craft.entries.{
    section(: 'news').,
    type(: 'audio').,
    relatedTo(: category).,
    search: searchTerm
} %}

{% for entry in craft.entries(searchentryParams) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

.

This would list all the entries which are

a) in a section named "news"
b) given an entry type (and entry template) "audio"
c) related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
d) matching to the search term "basketball OR soccer"

  1. in a section named "news"
  2. given an entry type (and entry template) "audio"
  3. related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
  4. matching to the search term "basketball OR soccer"

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

For example:

{% set category = craft.categories.group('audioCategories').slug('podcasts').first() %}
{% set search = 'basketball OR soccer' %}

{% for entry in craft.entries.section('news').type('audio').relatedTo(category).search(search) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

This would list all the entries which are

a) in a section named "news"
b) given an entry type (and entry template) "audio"
c) related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
d) matching to the search term "basketball OR soccer"

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

For example:

{% set categoryParams = {
    group: 'audioCategories',
    slug: 'podcasts'
} %}

{% set category = craft.categories(categoryParams).first() %}
{% set searchTerm = 'basketball OR soccer' %}

{% set entryParams = {
    section: 'news',
    type: 'audio',
    relatedTo: category,
    search: searchTerm
} %}

{% for entry in craft.entries(entryParams) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

.

This would list all the entries which are

  1. in a section named "news"
  2. given an entry type (and entry template) "audio"
  3. related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
  4. matching to the search term "basketball OR soccer"
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

Sure it's possible. There's the type() parameter available for ElementCriteriaModels to filter the returned results by only those entry types you need.

For example:

{% set category = craft.categories.group('audioCategories').slug('podcasts').first() %}
{% set search = 'basketball OR soccer' %}

{% for entry in craft.entries.section('news').type('audio').relatedTo(category).search(search) %}
    <li>{{ entry.title }}</li>
{% endfor %} 

This would list all the entries which are

a) in a section named "news"
b) given an entry type (and entry template) "audio"
c) related to a category from the category group "audioCategories" (I query just a single cat. to keep it simple)
d) matching to the search term "basketball OR soccer"