2

I have an entry type whose content will be separated from the main content. So I was wondering how can we give an entry type its own search and categories? Possible?

3

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.