2

I have 2 input fields that users can use to search.

The first field is for searching job application titles.

The second field is for searching the job application's field of expertise.

If the first field is filled in the outcome should be based on the first field only. If the second field is filled in the outcome should be based on the second field only.

When both are filled in they should work together in filtering the search words that are entered in the fields.

<div class="zoekvelden">
        {exp:low_search:form 
          result_page="zoek/vac-resultaten"
          collection="vacatures"
          exact="vacature|vakgebied" 
        }
        <div class="zvacature">
            <h2>Zoek op vacature</h2>
            {!-- <input type="hidden" name="collection" value="5"> --}
            <input type="search" name="vac:vacature" placeholder="bijv. {vacatures_functie_titel}">
        </div>
        <div class="zvakgebied">
            <h2>Zoek op vakgebied</h2>
            {!-- <input type="hidden" name="collection" value="6"> --}
            <input type="search" name="vac:vakgebied" placeholder="bijv. {vacatures_vakgebied}">
        </div>
        <button type="submit">Gaan!</button>
        {/exp:low_search:form }
    </div>

This is what I have so far on the input side. I actually made 2 collections that I wanted to use: 'vacatures' and 'vacatures_vakgebied' but I haven't made it that far because I can't even get 1 collection to work.

I also found this question and I tried the same method as he was using and what was suggest he should do.

Still no luck.

{exp:low_search:results query="{segment_3}" alias:keywords="vac"}
                {if count ==  1}

                <p>U zocht naar: <i>{exp:low_search:param get="vac" query="{segment_2}"}</i> ({total_results} resultaten)</p>
                <br/><br />
                <div class="vac">{/if}
                  <div class="icon">
                      <i class="fa {vacatures_font_awesome}"></i>
                  </div>
                  <div class="info">
                      <h2>{vacatures_functie_titel}</h2>
                      <p class="blauw"><span class="blauw">Plaats: </span>{vacatures_plaats}</p>
                      <p><span class="oranje">Niveau: </span>{vacatures_niveau}</p>
                      <p class="blauw"><span class="blauw">Uren p/w: </span>{vacatures_uren_p_w}</p>
                      <p><span class="oranje">Vakgebied: </span>{vacatures_vakgebied}</p>
                      <div class="margin_bottom5">
                          {exp:eehive_hacksaw words="32" allow = "<br>"}
                          {vacatures_functie_omschrijving}
                          {/exp:eehive_hacksaw}...
                      </div>
                      <a href="{url_title}" class="button">Lees verder</a> 
                  </div>
                {if count == total_results}
                </div>{/if}
                <div class="divider_line8 nomargin"></div>

                {if no_results}
                <div class="whoops">
                  <h2>Excuses</h2>
                  We hebben helaas geen resultaten gevonden voor uw zoekopdracht. Probeer het nog eens met een andere zoekopdracht.
                  {exp:low_search:suggestions keywords="{low_search_keywords}" keywords:lang="nl" limit="2"}
                    {if suggestion_count == 1}Bedoelt u:{/if}
                    <a href="{low_search:url keywords="{suggestion}"}">{suggestion}</a>{if suggestion_count != total_suggestions}&nbsp;of&nbsp;{if:else}?{/if}
                    {if no_suggestions}Controleer de spelling of probeer een nieuwe zoekopdracht.{/if}
                  {/exp:low_search:suggestions}

                  {/if}
                </div>
              {/exp:low_search:results}

This is the output. It should retrieve the entries that have the mentioned search words in the title or in the entry description. But instead it gives me all the search results as if it doesn't look at the collection it should be using.

Thank you for taking the time reading my question any help is much appreciated!

3

First of all, the general setup of your search form could be better to work correctly with Low Search. You’re targeting 2 different collections using two different fields. Instead of that, I’d opt for a single input field and a drop down to select the collection. Something like this:

{exp:low_search:form result_page="zoek/vac-resultaten"}
    <input type="search" name="keywords">
    <select name="collection">
        <option value="5">Vacatures</option>
        <option value="6">Vakgebieden</option>
        <option value="5|6">Beide</option>
    </select>
    <button type="submit">Zoeken</button>
{/exp:low_search:form}

Note that you do not define any filter parameters in the Form tag (read this carefully). In your case, that means the collection parameter (moved to an input field in the form) and the exact parameter (part of the Field Search filter and not relevant here, since you're using the Keywords filter instead).

Also note that you should use name="keywords" to trigger the Keywords filter. You could also use an alias, but the way you've implemented it is wrong. You could use name="vac" for your keywords, and then use alias:keywords="vac" -- where the value of both parameters are exactly the same.

Then, your Results tag. You're pointing to query="{segment_3}", which makes sense when you're using result_page="zoek/vac-resultaten" in the Form tag. However, in the first conditional, you want to output the keywords using the Params tag, which points to {segment_2}. That won't work, and isn't necessary either. You could just use {low_search_keywords} to output the given keywords. Like you're using in the Suggestions tag.

Finally, make sure your collections have at least one field with weight >= 1.


| improve this answer | |
  • Wow thanks Low! :D I read the documentation a couple of times unfortunately for me, a beginner in Expression Engine & Low Search for that matter it's a bit challenging to understand what's being explained if that makes sense. Anyway thank you for your help! – Jeffrey Stevens Feb 22 '17 at 8:22
  • Something that I didn't tell is that I am obliged to have 2 input fields since the client approved the design that had 2 input fields... Do you have a solution for 2 input fields that perhaps could work together if they are both filled in? – Jeffrey Stevens Feb 22 '17 at 10:58
  • Not really, no. Low Search's Keywords filter simply isn't designed to use more than one input field. You'd have to create a custom extension to make something like that work, – Low Feb 22 '17 at 18:56

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.