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.

Adding searched for keywords to new search form

May 02, 2012 8:45pm

Subscribe [2]
  • #1 / May 02, 2012 8:45pm

    Jon Rhoades

    6 posts

    Apologies if this has already been answered, but I’m having a nightmare searching for the term “search”...

    Anyway I’m trying to do something like this: on the search result page, have the keywords that have been searched for repopulate a new search box so that people can adjust them and search again. 

    The first use of the keywords variable works fine, but , the value of {exp:search:keywords} within the simple search form shows up as (for instance) “M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr” as presumably it’s no referring the {exp:search:simple_search}, rather than {exp:search:search_results}.

    {exp:search:search_results}
        {if count == 1}
        <div id="search_results">
            <h3>Your search for <em>"{exp:search:keywords}"</em> found {total_results} result{if total_results > 1}s{/if}</h3>
    <p>        <div id="search_again"><br />
                {exp:search:simple_form form_id="search" search_in="everywhere" result_page="svi/results" } <br />
                    <input name="keywords" type="text"   size="40" value="{exp:search:keywords}" /><br />
                    <input name="submit"   type="submit" value="Search again"><br />
                {/exp:search:simple_form}<br />
        {/if}<br />
    snip….<br />
    {/exp:search:search_results}

    I can always set it using a variable (I’ve made a simple key value extension for moments like this) or I can set it by Javascript by putting the first use of it into a div and change the value of the keywords input that way. 

    But surely this is a common problem that has a better solution?

    Cheers Jon

  • #2 / May 03, 2012 1:51am

    Jon Rhoades

    6 posts

    It seems that both forms on the page had the same id…

    When my design guy fixed that, {exp:search:keywords} showed the real keywords, not the encoded junk.  Who knew.

    Please mark as resolved

    Cheers Jon

  • #3 / May 03, 2012 12:23pm

    Shane Eckert

    7174 posts

    Hello Jon,

    Nice work here! Glad that you got this figured out.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases