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.

Keyword search result to fill input form

March 22, 2011 10:30am

Subscribe [3]
  • #1 / Mar 22, 2011 10:30am

    Sam Sullivan

    64 posts

    Is it possible to show the keyword search result word inside a form input value? when I did a test, it just creates a string of numbers.

    <input type="text" name="company" value="{exp:search:keywords}" />

    Moved to CodeShare Corner by Moderator

  • #2 / Mar 22, 2011 3:53pm

    Rob Allen

    3118 posts

    Is this on a search results page?

  • #3 / Mar 22, 2011 4:12pm

    Sam Sullivan

    64 posts

    I’m not using a results page, it’s just a single tag, but you got me thinking so just I tried it in regular <form> and works, the form I’m using is from User register - exp:user:register - I guess might be question for Solspace.

  • #4 / Mar 22, 2011 5:15pm

    Rob Allen

    3118 posts

    Ah, the {exp:search:keywords} tag is only used on a search results page so that’s why it’s not outputting anything sensible.

    You could pass a keyword via a segment, eg http://www.mysite.com/entry/keyword and use that value in the form somewhere…

    <input type="text" name="subject" value="{segment_2}" />

    Are you trying to include data from a previous page or an entry?

  • #5 / Mar 22, 2011 7:07pm

    Sam Sullivan

    64 posts

    I’m using simple search and getting results ok using {exp:search:keywords} in a regular template, but doesn’t work when it’s inside the User’s {exp:user:register} form. However….

    It would solve all my problem if I could use {segment_X}, but how do I get the keyword into the URL? it just shows the search string of numbers at the moment.

  • #6 / Mar 22, 2011 8:31pm

    Rob Allen

    3118 posts

    Hmm strange, I would have thought that the tag would have parsed fine inside {exp:user…} but I tested in and it does’t! It looks like some of the user:register module doesn’t like that tag, so it’s probably one for Solspace to help on.

    I don’t know of a way of passing a URL segment with a search unfortunately, though it’s straightforward using non-search methods!

  • #7 / Mar 23, 2011 6:43am

    Sam Sullivan

    64 posts

    Thanks for testing too.

    Yes, I’m a fan of segments, often got me out of a pickle or two, not here though.

    I’ve posted a new topic at Solspace forum.

  • #8 / Mar 23, 2011 12:24pm

    Sam Sullivan

    64 posts

  • #9 / Mar 23, 2011 12:47pm

    Rob Allen

    3118 posts

    Ah that’s interesting, I actually tested preload_replace and it didn’t work 😊

    Glad you found a solution anyway!

  • #10 / Mar 23, 2011 12:52pm

    Sam Sullivan

    64 posts

    it didn’t! sorry, I screwed up my test, still unresolved, gonna have to give up soon, or start new topic at Solspace.

  • #11 / Mar 23, 2011 2:06pm

    Rob Allen

    3118 posts

    Lol… been there a few times.

    I think the issue is that the User reg form is specifically expecting member fields, or member custom fields., and anything outside those parameters gets ignored/not processed.

  • #12 / Mar 24, 2011 7:22am

    Sue Crocker

    26054 posts

    Thanks for the assist, Rob.

    Sam, since this appears to be an issue with Solspace, moving this over to the CodeShare Corner to continue the conversation.

  • #13 / Jul 17, 2014 5:57am

    I’m getting a similar issue, when trying to use the {exp:search:keywords} tag on my No Results page.

    <h1>Search Results for : {exp:search:keywords}</h1>
    {exp:search:simple_form channel="news" search_in="entries" where="all" no_result_page="search/no-results" result_page="search/results"}
     <input name="keywords" type="text" value="{exp:search:keywords}" maxlength="100">
     <button type="submit">Search</button>
    {/exp:search:simple_form}

    It displays fine in the H1 tag, but it outputs a random looking set of characters in the Search form’s input field.

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

ExpressionEngine News!

#eecms, #events, #releases