Exactly match x3 custom fields
What I'd like to achieve is:
1. User enters data into x3 form fields
2. IF all 3 fields are exactly as stored in the channel then a custom field (excerpt) is displayed in the search results.
At the moment the results are returning even if the words dont fully match. So for example "1234" and "12345" both return results, as "1234" is part of both of those queries. Same for "Steven", searching for "stev" also works.
Search Form:
{exp:low_search:form
result_page="/site/success"
required="search:firstname|search:surname|search:clientref"
}
<div class="form-area">
<p class="form-element">
<label for="firstname">First name<em>*</em></label>
<input type="text" name="search:firstname" id="firstname" class="txtbox">
</p>
<p class="form-element">
<label for="surname">Surname<em>*</em></label>
<input type="text" name="search:surname" id="surname" class="txtbox">
</p>
<p class="form-element">
<label for="clientref">Client Ref<em>*</em></label>
<input type="text" name="search:clientref" id="clientref" class="txtbox nowhite">
</p>
</div>
<input type="submit" id="submit" class="submit" value="Submit ›" />
{error_message}
{/exp:low_search:form}
Results page:
{exp:low_search:results
query="{segment_3}"
keywords:stem="no"
exact="search:firstname|search:surname|search:clientref"
}
<p>{title} {first_name} {surname} ({client_ref})</p>
<h1>Discount Code: <br/>{discount}</h1>
{if no_results}No search results{/if}
{/exp:low_search:results}
Thanks in advance for your time, really appreciate it. The docs look very comprehensive I just cannot seem to get my head around it..
Replies
Low 16 Aug 2016 10:18
I'll need to take a look myself. Please send SuperAdmin login credentials to hi at gotolow dot com if you can.
Low 16 Aug 2016 10:37
OK, you have to make sure the field names match.
You're using search:firstname while the name of the field actually is {first_name}, so you need to use search:first_name. Same goes for search:clientref vs. search:client_ref.
I made the changes in your template, and that works.
Mark 16 Aug 2016 10:48
Geez, something so simple. Thanks Low. really appreciate it.