1

Has anyone used Croxton's Search Fields plugin? This is my first time using it. I'm trying to get a search form working and am running into difficulties getting it to pull results. Ordinarily I'd just use the normal Simple Search module, but I need different search fields to search specific custom fields.

Here is what I have so far:

    <form>
    <p>
            <label for="keywords">Property Name:</label><br>
            <input type="text" name="keyword" id="keyword" />
    </p>
    <p>
            <label for="keywords">County:</label><br>
            <input type="text" name="county" id="county" />
    </p>
    <p>
            <input type="hidden" name="XID" value="{XID_HASH}" />
            <input type="submit" value="submit" class="submit">
    </p>
    </form>
    {exp:search_fields
    search:title="keyword" 
    search:county="county" 
    channel="available_site" 
    operator="OR"
    parse="inward"}{search_results}
      {exp:channel:entries entry_id="{search_results}" disable="member_data|categories" dynamic="no" orderby="title" sort="asc" limit="10"}
        <a href="{page_url}">{title}</a>
      {/exp:channel:entries}
    {/exp:search_fields}

I'm sure I've just missed something simple, but I can't find it. Thanks!

UPDATE:

I've adjusted it again to more closely resemble the example in the readme, but I'm still not any results.

Here is my search page:

        <form method="post">
    <p>
            <label>Property Name:</label><br>
            <input type="text" name="search:title" />
    </p>
    <p>
            <input type="hidden" name="XID" value="{XID_HASH}" />
            <input type="submit" value="submit" class="submit">
    </p>
    </form>
    {embed="properties/search_results" search='{exp:get_parameters post="search"}'}

and the embedded search results template

{exp:search_fields 
search:title="{embed:search}" 
operator="OR" 
channel="available_site" 
parse="inward"}

<p>Search results for &lsquo;<em>{embed:search}</em>&rsquo;</p>
{exp:channel:entries channel="available_site" entry_id="{search_results}" disable="member_data|categories" dynamic="no" orderby="title" sort="asc" limit="10"}

    <a href="{page_url}">{title}</a>

    {paginate}
    <div class="pagination">
        <ul>
            <li class="previous">{if previous_page}<a href="{auto_path}">Prev</a>{/if}</li>
            <li class="next">{if next_page}<a href="{auto_path}">Next</a>{/if}</li>
        </ul>
        <p>Page {current_page} of {total_pages}</p>
    </div>
    {/paginate}

{/exp:channel:entries}

{if no_results}
    <p class="intro">Sorry, no matches were found for &lsquo;<em>{embed:search}</em>&rsquo;.</p>
{/if}

{/exp:search_fields}

But I just get the message "Sorry, no matches were found for ." It doesn't look like any information at all is being passed from the form to the results template.

any ideas?

  • I'd recommend embedding the search tags in an embed as per the instructions: github.com/croxton/Search_fields/blob/master/… – stuartmcd69 Mar 26 '16 at 2:25
  • 1
    I've adjusted the form to more closely resemble the readme (see the UPDATE above), but I'm still not getting anything passed from the form to the results page. – Marketing Alliance Mar 28 '16 at 13:40
  • Do you have the get_parameters plugin installed as well? – Jeremy Gimbel Apr 3 '16 at 14:38
  • Yes, I do have the get_parameters plugin installed. – Marketing Alliance Apr 4 '16 at 20:57
0

From what I can see, you're mixing up two different methods of using Search Fields. You can use the dynamic parameters parameter without using the get_parameters plugin. I've never done this, but it should work. Your code would look like this:

<form method="post">
    <p>
        <label for="keywords">Property Name:</label><br>
        <input type="text" name="search:title" id="keyword" />
    </p>
    <p>
        <label for="keywords">County:</label><br>
        <input type="text" name="search:county" id="county" />
    </p>
    <p>
        <input type="hidden" name="XID" value="{XID_HASH}" />
        <input type="submit" value="submit" class="submit">
    </p>
</form>
{exp:search_fields
    dynamic_parameters="title|county" 
    channel="available_site" 
    operator="OR"
    parse="inward"
}
    {exp:channel:entries entry_id="{search_results}" disable="member_data|categories" dynamic="no" orderby="title" sort="asc" limit="10"}
        <a href="{page_url}">{title}</a>
  {/exp:channel:entries}
{/exp:search_fields}
| improve this answer | |
  • I made a few changes, but using the dynamic_parameters option seems to be the trick. My search form is now working, and it is pulling results! I'll post my final code shortly. Thanks a ton, Jeremy! – Marketing Alliance Apr 4 '16 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.