We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Searching Within a Group of Channels or Just One

How Do I?

jlcolema's avatar
jlcolema
6 posts
9 years ago
jlcolema's avatar jlcolema

I’m trying to create a search form where one can choose to search within a certain group of channels or just one. These options are part of a select element within the form:

Example select element options:

  1. All Types (selected by default; searches within the FAQs, Videos, Forms & Resources, Tools & Apps and Compliance Watch channels).
  2. FAQs
  3. Videos
  4. Forms & Resources
  5. Tools & Apps
  6. Compliance Watch

Using the advanced search form, I’ve figured out how to get the search working for individual channels, but not for the first one (All Types).

Is it possible to combine the channel ID’s for FAQs, Videos, Forms & Resources, Tools & Apps and Compliance Watch into the value for “All Types”? Hopefully I’m just overlooking something.

The following is what I have currently (some things are hard-coded at the moment – sorry!):

{exp:search:advanced_form result_page='support-center/results' results='5'}

 <ul>

  <li>

   <label for="keywords">Search our Support Center</label>

   <input type="text" name="keywords" id="keywords" value="" placeholder="Search Our Support Center" />

  </li>

  <li>

   <label>Filter</label>

   <select id="channel_id" name='channel_id[]'>

    <option value="" selected="selected">All Types</option>
    <option value="7">FAQs</option>
    <option value="9">Videos</option>
    <option value="11">Forms & Resources</option>
    <option value="13">Tools & Apps</option>
    <option value="15">Compliance Watch</option>

   </select>

  </li>

 </ul>

 <button type="submit">Search</button>

{/exp:search:advanced_form}
       
Jeremy S.'s avatar
Jeremy S.
353 posts
9 years ago
Jeremy S.'s avatar Jeremy S.

Have you tried separating the ids with a pipe ‘|’

<option value="11|12">Forms & Resources</option>
       
jlcolema's avatar
jlcolema
6 posts
9 years ago
jlcolema's avatar jlcolema

Hi Jeremy. Thanks for checking this out!

I should have mentioned in my original post that I did try that:

Example:

<option value="7|9|11|13|15">All Types</option>

With this selected, the search shows results for all channels within the system (Testimonials, Advertisements, etc.).

       
Jeremy S.'s avatar
Jeremy S.
353 posts
9 years ago
Jeremy S.'s avatar Jeremy S.

Have you tried instead excluding the ones you don’t want?

<option value="not 1|2|3">All Types</option>
       
jlcolema's avatar
jlcolema
6 posts
9 years ago
jlcolema's avatar jlcolema

Yes. That ends up doing the same thing, too (showing results for all channels).

       
Jeremy S.'s avatar
Jeremy S.
353 posts
9 years ago
Jeremy S.'s avatar Jeremy S.

Have you tried using the channel short names instead of ids, in both methods to see what happens? What version of ExpressionEngine?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.