Answers.Body: <p>I suspect the only way to do this at the moment would be to look up the <code>EntryType</code>s for each of the desired Sections, and filter just by those—ignoring the <code>section</code> query facet. For example:</p>
  <pre><code>{# Map some Section handles into actual Section models, using the Sections Service: #}
  {% set sections = ['one', 'two', 'three'] | map((h) =&gt; craft.app.sections.getSectionByHandle(h) %}
  
  {# List your &quot;forbidden&quot; Entry Types in a `sectionHandle:entryTypeHandle` format, so we can filter them out, in a moment: #}
  {% set forbiddenEntryTypes = [
    'mySection:entryTypeOne',
    'mySection:entryTypeTwo'
  ] %}
  
  {% set entryTypes = [] %}
  
  {% for section in sections %}
    {# Get the section's EntryTypes, filtering out any that don't match our &quot;magic&quot; `section:entryType` values in the &quot;forbidden&quot; array, above: #}
    {% set permittedSectionEntryTypes = section.getEntryTypes() | filter((t) =&gt; &quot;#{section.handle}:#{t.handle}&quot; not in forbiddenEntryTypes) %}
  
    {# Merge anything that passes the test into the main `entryTypes` array: #}
    {% set entryTypes = entryTypes | merge(permittedSectionEntryTypes) %}
  {% endfor %}
  
  {% set query = craft.entries({
    type: entryTypes
  }) %}
  </code></pre>
  <p>This basically works by assuming you want <em>all types from all sections</em>, then filtering out just a few types from that list.</p>
  <p>For example, your <code>forbiddenEntryTypes</code> might look something like this, if you had three other Entry Types in the Courses section…</p>
  <pre><code>{% set forbiddenEntryTypes = [
    'courses:night',
    'courses:takeHome'
  ] %}
  </code></pre>
  <p>…where <code>cce</code> is allowed, because it's returned by the section, but not explicitly filtered out. You'll have to update this if/when you add more Course types!</p>
  <blockquote>
  <p><strong>Keep in mind</strong> that the <code>sectionHandle:entryTypeHandle</code> format is not a Craft feature, it's just a way for us to compare Section + Entry Type handles at once (note the way we build the <code>&quot;#{section.handle}:#{t.handle}&quot;</code> string when filtering down the Entry types)!</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-16T21:33:47.767Z
Answers.LastActivityDate: 2020-11-16T21:49:17.433Z
Answers.LastEditDate: 2020-11-16T21:49:17.433Z
Answers.UserDisplayName: August Miller
Answers.Body: <p>Thank you for the help August!</p>
  <p>I was able to get this work as intended. The only issue we ran into was getting an error for {type: entryTypes} when it was an an array of EntryTypes.</p>
  <p>Here is the finished code:</p>
  <pre><code>{% set sections = [ 'pages', 'careerPaths', 'courses', 'events', 'eventsIndex', 'news', 'newsIndex', 'programs', 'allPrograms', 'facultyStaff', 'facultyStaffIndex' ] | map((h) =&gt; craft.app.sections.getSectionByHandle(h)) %}
  
  {# List your &quot;forbidden&quot; Entry Types in a `sectionHandle:entryTypeHandle` format, so we can filter them out, in a moment: #}
  {% set forbiddenEntryTypes = [
      'courses:standard',
      'courses:cceCertificate'
  ] %}
  
  {% set entryTypes = [] %}
  
  {% for section in sections %}
      {# Get the section's EntryTypes, filtering out any that don't match our &quot;magic&quot; `section:entryType` values in the &quot;forbidden&quot; array, above: #}
      {% for entryType in section.getEntryTypes() | filter((t) =&gt; &quot;#{section.handle}:#{t.handle}&quot; not in forbiddenEntryTypes) %}
          {% set entryTypes = entryTypes | merge([entryType.handle])%}
      {% endfor %}
  
  {% endfor %}
  
  {# dd entryTypes #}
  {% set params = params|merge({ type: entryTypes }) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-17T20:35:19.547Z
Answers.Text: Nice! Alternatively, as you merge the value in with you query, you could use `entryTypes | column('id')` so that you're not discarding any actionable info until the last moment—using `id` may also prevent additional queries, as the `handle` ultimately needs to get mapped to an ID anyway! (This may well be cached/memoized on the Sections service…)
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-17T17:25:38.003Z
Answers.LastActivityDate: 2020-11-17T20:20:52.613Z
Answers.LastEditDate: 2020-11-17T20:20:52.613Z
Answers.UserDisplayName: weslawson
Body: <p>I am currently searching within multiple sections on my site.</p>
  <p>I'd like to limit one of the sections (<code>courses</code>) to a specific entry type (<code>cce</code>)?</p>
  <p>Any help would be greatly appreciated!</p>
  <pre class="lang-php prettyprint-override"><code>{% set params = { 
      section: [ 'pages', 'careerPaths', 'courses', 'events', 'eventsIndex', 'news', 'newsIndex', 'programs', 'allPrograms', 'facultyStaff', 'facultyStaffIndex' ], 
      limit: siteVariables.resultsLimitForPagination 
  } %}
  
  {# if search term exists, search #}
  {% set searchTerm = craft.app.request.getParam('q') %}
  
  {% if searchTerm|length %}
      {% set params = params|merge({ groupBy: ['title'] }) %}
      {% set params = params|merge({ search : searchTerm, orderBy: 'score DESC'}) %}
  {% endif %}
  
  {# Query #}
  {% set query = craft.entries(params)  %}
  
  {% paginate query as pageInfo, entries %} 
  </code></pre>
  
Tags: <craft3><search><sections><entry-type><params>
Title: Specify a specific entry type in paramaters
ThreadText: # Specify a specific entry type in paramaters
  
  (Asked by: username_0 on 2020-11-16)
  
  I am currently searching within multiple sections on my site.
  
  I'd like to limit one of the sections (`courses`) to a specific entry type (`cce`)?
  
  Any help would be greatly appreciated!
  
  ```php
  {% set params = { 
      section: [ 'pages', 'careerPaths', 'courses', 'events', 'eventsIndex', 'news', 'newsIndex', 'programs', 'allPrograms', 'facultyStaff', 'facultyStaffIndex' ], 
      limit: siteVariables.resultsLimitForPagination 
  } %}
  
  {# if search term exists, search #}
  {% set searchTerm = craft.app.request.getParam('q') %}
  
  {% if searchTerm|length %}
      {% set params = params|merge({ groupBy: ['title'] }) %}
      {% set params = params|merge({ search : searchTerm, orderBy: 'score DESC'}) %}
  {% endif %}
  
  {# Query #}
  {% set query = craft.entries(params)  %}
  
  {% paginate query as pageInfo, entries %} 
  
  ```
  
  **Tags:** craft3, search, sections, entry-type, params
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-11-16. Score: 1 | Accepted answer
  
  I suspect the only way to do this at the moment would be to look up the `EntryType`s for each of the desired Sections, and filter just by those—ignoring the `section` query facet. For example:
  
  ```
  {# Map some Section handles into actual Section models, using the Sections Service: #}
  {% set sections = ['one', 'two', 'three'] | map((h) => craft.app.sections.getSectionByHandle(h) %}
  
  {# List your "forbidden" Entry Types in a `sectionHandle:entryTypeHandle` format, so we can filter them out, in a moment: #}
  {% set forbiddenEntryTypes = [
    'mySection:entryTypeOne',
    'mySection:entryTypeTwo'
  ] %}
  
  {% set entryTypes = [] %}
  
  {% for section in sections %}
    {# Get the section's EntryTypes, filtering out any that don't match our "magic" `section:entryType` values in the "forbidden" array, above: #}
    {% set permittedSectionEntryTypes = section.getEntryTypes() | filter((t) => "#{section.handle}:#{t.handle}" not in forbiddenEntryTypes) %}
  
    {# Merge anything that passes the test into the main `entryTypes` array: #}
    {% set entryTypes = entryTypes | merge(permittedSectionEntryTypes) %}
  {% endfor %}
  
  {% set query = craft.entries({
    type: entryTypes
  }) %}
  
  ```
  
  This basically works by assuming you want *all types from all sections*, then filtering out just a few types from that list.
  
  For example, your `forbiddenEntryTypes` might look something like this, if you had three other Entry Types in the Courses section…
  
  ```
  {% set forbiddenEntryTypes = [
    'courses:night',
    'courses:takeHome'
  ] %}
  
  ```
  
  …where `cce` is allowed, because it's returned by the section, but not explicitly filtered out. You'll have to update this if/when you add more Course types!
  
  > **Keep in mind** that the `sectionHandle:entryTypeHandle` format is not a Craft feature, it's just a way for us to compare Section + Entry Type handles at once (note the way we build the `"#{section.handle}:#{t.handle}"` string when filtering down the Entry types)!
  
  
  ---
  
  ### Answer by username_0 on 2020-11-17. Score: 1
  
  Thank you for the help username_1!
  
  I was able to get this work as intended. The only issue we ran into was getting an error for {type: entryTypes} when it was an an array of EntryTypes.
  
  Here is the finished code:
  
  ```
  {% set sections = [ 'pages', 'careerPaths', 'courses', 'events', 'eventsIndex', 'news', 'newsIndex', 'programs', 'allPrograms', 'facultyStaff', 'facultyStaffIndex' ] | map((h) => craft.app.sections.getSectionByHandle(h)) %}
  
  {# List your "forbidden" Entry Types in a `sectionHandle:entryTypeHandle` format, so we can filter them out, in a moment: #}
  {% set forbiddenEntryTypes = [
      'courses:standard',
      'courses:cceCertificate'
  ] %}
  
  {% set entryTypes = [] %}
  
  {% for section in sections %}
      {# Get the section's EntryTypes, filtering out any that don't match our "magic" `section:entryType` values in the "forbidden" array, above: #}
      {% for entryType in section.getEntryTypes() | filter((t) => "#{section.handle}:#{t.handle}" not in forbiddenEntryTypes) %}
          {% set entryTypes = entryTypes | merge([entryType.handle])%}
      {% endfor %}
  
  {% endfor %}
  
  {# dd entryTypes #}
  {% set params = params|merge({ type: entryTypes }) %}
  
  ```
  
  > **Comments:**
  > **username_1**: Nice! Alternatively, as you merge the value in with you query, you could use `entryTypes | column('id')` so that you're not discarding any actionable info until the last moment—using `id` may also prevent additional queries, as the `handle` ultimately needs to get mapped to an ID anyway! (This may well be cached/memoized on the Sections service…)  
  
  ---
  
  