ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Simple Search within a specific Category

August 13, 2013 7:27pm

Subscribe [2]
  • #1 / Aug 13, 2013 7:27pm

    adamprocter

    228 posts

    I have simple search working rather well but I want to expand it slightly to search within one specific category ?

    Is this possible with simple search? or do I need to create an advanced search with a pre filled in form (hidden), if so any sample code would be grand as I was struggling to pull apart the EE doc code apart

    I was hoping I could just add category as a variable to simple search like this…

    {exp:search:simple_form channel="news" category="46" search_in="everywhere" status="open" 
     where="all" result_page="search/searchresults" no_result_page="search/noresults"}
    <div id="searching">
    <input id="searchbox" name="keywords" placeholder="Search Projects"/>
    <button id="search" name="submit" type='submit'><i class='icon-search'></i></button>
    </div>
    {/exp:search:simple_form}
  • #2 / Aug 14, 2013 8:30am

    Boyink!

    5011 posts

    Category isn’t listed as a parameter on the simple search tag:

    http://ellislab.com/expressionengine/user-guide/modules/search/simple.html#parameters

    So, no, it’s not possible.

    Depending on your need possibly a channel:entries tag, the search_in parameter, and feeding a value to a URL segment?

  • #3 / Aug 14, 2013 8:35am

    adamprocter

    228 posts

    Can I not just create a hidden advanced search form with the other values prepopulated ?

  • #4 / Aug 14, 2013 8:38am

    Boyink!

    5011 posts

    I don’t know…can you? 😉

    It’s not something I’ve done…but might be a solution..

  • #5 / Aug 14, 2013 9:03am

    adamprocter

    228 posts

    Here is the answer :D

    {exp:search:advanced_form result_page="search/searchtest"}
    
                  <input type="text" class="input" name="keywords" />
    <!--                 hidden values to search everything in News with Category Project     -->
                   <input type="hidden" name="search_in" value="everywhere" />
                   <input type="hidden" name="where" value="all" />
                   <input type="hidden" id="channel_id" name='channel_id[]' value="7" />
                   <input type="hidden" name="cat_id[]" value="45">
          
         <input type='submit' value='Search' class='submit' />
       
    
    {/exp:search:advanced_form}
  • #6 / Aug 14, 2013 9:07am

    adamprocter

    228 posts

    update

  • #7 / Aug 14, 2013 9:12am

    adamprocter

    228 posts

    updated original solution

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases