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.

Persistant category searching

March 20, 2012 8:45am

Subscribe [2]
  • #1 / Mar 20, 2012 8:45am

    tmask

    5 posts

    Hello, this is my first post on the forum and ive just recently started using EE and I love it 😊 I do have one question with regards to searching. The site im working on is like a small search engine. There are multiple channels with multiple categories in each. Im looking for a way to search inside a specific category or have EE remember what category I just came from when i search.  Say im in a channel called News and i click on the Sports category, I can search that Sports category once just fine but when it takes me to my search/results template all subsequent searches give results for the entire News channel.

    Since im on the search/results channel now i cant use {segment_x} to nab the category from the url. Is there some way of telling a results page what category I just came from or left so I can continue to just search that category? Or does each category have to have their own results template hard coded?

    Thanks so much 😊

  • #2 / Mar 20, 2012 2:52pm

    MID

    166 posts

    Or does each category have to have their own results template hard coded?

    I think so, yes.

    I have wanted to do this in the past, so would be interested if anyone knows how to do it.  Or if it’s a feature request, I second it!

  • #3 / Mar 21, 2012 3:22pm

    Dan Decker

    7338 posts

    Hi tmask,
    Welcome to ExpressionEngine and the Forums! We’re happy you’re here!

    Are you using the simple search form or the advanced search form from your news->sports page?

    I have an idea using a hidden form input and the plugin Server Variable, but I would love to see your search and results templates.

    Cheers,

  • #4 / Mar 21, 2012 8:02pm

    tmask

    5 posts

    Thanks for the welcome 😊 here is what i got so far:

    here is my form code:

    {exp:search:advanced_form channel="News" result_page="index/results" search_in="everywhere"}

    <input type=“text” name=“keywords” id=“keywords”/>
    <input type=“hidden” name=“catid” value=“1”>
    <input type=“submit” value=“search”/>

    {/exp:search:advanced_form}

    I just cant seem to get that hidden variable to post to my results page
    and my results template:

    {exp:search:total_results} Result(s) for {exp:search:keywords}</h2>
    <ul>
    {exp:search:search_results}
    <li>{title}<br>{excerpt}<br></li>
    {/exp:search:search_results}
    </ul>
    <hr size=“1”>

    {exp:server_var:post}
    {exp:server_var:get}


    Im assuming my hidden form entry should be pulled by one of the above server_var calls, but it just outputs an empty array. Ive also tried another similar module “evopost” which should do the same thing as Server Variable but i still get no returns.

  • #5 / Mar 23, 2012 7:37pm

    Sean C. Smith

    3818 posts

    Hi tmask,

    I know that evopost won’t work for you as you need to have access to the action url for your form and with the search module you don’t get that. I suspect that it’s the same for the add-on that Dan linked to above. have you considered a third party search module such as Low Search or Super Search?

    Sean

  • #6 / Mar 24, 2012 10:35am

    tmask

    5 posts

    Nice, ill look into those 😊 thanks so much

  • #7 / Mar 26, 2012 8:25pm

    Sean C. Smith

    3818 posts

    tmask,

    Is there anything else I can do to help?

    Sean

  • #8 / Mar 26, 2012 10:15pm

    tmask

    5 posts

    Nope that answers all my questions, thanks so much

  • #9 / Mar 29, 2012 5:29pm

    Shane Eckert

    7174 posts

    Hey tmask,

    I am glad this is all sorted for you now.

    Have a great rest of the week!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases