We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Pro Search Not Filtering

Development and Programming

weblion's avatar
weblion
12 posts
10 months ago
weblion's avatar weblion

I have followed the documentation and have tried several tests and debugs and I still get no results. It seems it has to do with parameters. Everytime I confirem it’s all setup correctly, I still bet the wrong results.

It’s a job search. I have a Channel Jobs, and category for each job type and a template for each job type. Job types meaning Truck Driver, Sales, Mechaninc, etc.

I have a search form template for each job type too. For Truck Drivers for instane the search form as these fields State, Route Type, and Trailer type. Each job entry has a state,route type and trailer type. I have confirmed I’m using the Pro Search paramaters, I have the Pro Search Collection configured correctly. But I always get the same results. When Searched by one of the paramaters I get a list of ALL truck driver jobs instead of just the ones in the state or trailer type or route tupe I selected to search.

Debugging show this:

State Filter (pro_search): {pro_search_field_id_17}

State Filter (GET): {get:state}

Trailer Type Filter: {get:trailer_type}

Route Type Filter: {get:route_type}

I just recently tried get: again after I tried other formats too.

I can’t seem to get this to work.

This is my form

<form method=”get” action=”{path='{segment_1}/openings’}”> <input type=”hidden” name=”csrf_token” value=”{csrf_token}”>

<div class=”mb-3”> <label for=”state” class=”form-label”>State</label> <select name=”search:field_id_17” id=”state” class=”form-select”> <option value=”“>All States</option> {exp:query sql="SELECT DISTINCT field_id_17 AS state FROM exp_channel_data_field_17 WHERE field_id_17 IS NOT NULL AND field_id_17 != '' ORDER BY state ASC"} <option value=”{state}” {if get:state == state}selected{/if}>{state}</option> {/exp:query} </select> </div>

<div class=”mb-3”> <label for=”trailer_type” class=”form-label”>Trailer Type</label> <select name=”search:field_id_14” id=”trailer_type” class=”form-select”> <option value=”“>All Trailer Types</option> {exp:query sql="SELECT DISTINCT field_id_14 AS trailer_type FROM exp_channel_data_field_14 WHERE field_id_14 IS NOT NULL AND field_id_14 != '' ORDER BY trailer_type ASC"} <option value=”{trailer_type}” {if get:trailer_type == trailer_type}selected{/if}>{trailer_type}</option> {/exp:query} </select> </div>

<div class=”mb-3”> <label for=”route_type” class=”form-label”>Route Type</label> <select name=”search:field_id_15” id=”route_type” class=”form-select”> <option value=”“>All Route Types</option> {exp:query sql="SELECT DISTINCT field_id_15 AS route_type FROM exp_channel_data_field_15 WHERE field_id_15 IS NOT NULL AND field_id_15 != '' ORDER BY route_type ASC"} <option value=”{route_type}” {if get:route_type == route_type}selected{/if}>{route_type}</option> {/exp:query} </select> </div>

<div class=”mb-3”> <label for=”city” class=”form-label”>City</label> <input type=”text” name=”search:field_id_16” id=”city” class=”form-control” value=”{get:city}” placeholder=”Enter City”> </div>

<div class=”mb-3”> <label for=”zip” class=”form-label”>Zip Code</label> <input type=”text” name=”search:field_id_18” id=”zip” class=”form-control” value=”{get:zip}” placeholder=”Enter Zip Code”> </div>

<button type=”submit” class=”btn btn-primary”>Search</button> </form>

This is what I have on my results page:

{exp:pro_search:results collection=”all-jobs” limit=”10” paginate=”bottom” orderby=”date” sort=”desc” category=”16” dynamic_parameters=”search:field_id_17|search:field_id_14|search:field_id_15” search:field_id_17=”{pro_search_field_id_17}” search:field_id_14=”{pro_search_field_id_14}” search:field_id_15=”{pro_search_field_id_15}” }
{if no_results} <div class=”alert alert-info”>No Truck Driver Jobs match your search criteria.</div> {/if}

      <div class="card mb-4 job-card">
        <div class="card-body">
          <h2 class="h4 mb-1">
            <a href="http://{url_title_path={segment_1}/details}">{title}</a>
          </h2>

            <i class="bi bi-geo-alt me-1"></i> {field_id_16}, {field_id_17}

          <div class="mb-3">
            {if entry_date > current_time - 86400}<span class="badge bg-success me-1">New</span>{/if}
            {if field_id_14}<span class="badge bg-secondary me-1">{field_id_14}</span>{/if}
            {if field_id_15}<span class="badge bg-secondary">{field_id_15}</span>{/if}
          </div>
          <a href="http://{url_title_path=%27{segment_1}/details%27}" class="btn btn-sm btn-primary">View Details</a>
        </div>
      </div>

      {paginate}
        <nav aria-label="Page navigation">
          <ul class="pagination">
            {pagination_links}
          </ul>
        </nav>
      {/paginate}

    {/exp:pro_search:results}

Any help would be appreciated.

       
Hop Studios's avatar
Hop Studios
481 posts
10 months ago
Hop Studios's avatar Hop Studios

Are you encoding the query in the URL? If so, you need query="{segment_3}" in the {exp:pro_search:results} tag.

You don’t want to use dynamic_parameters="search:field_id_17|search:field_id_14|search:field_id_15" – that’s a channel:entries parameter and not used in pro search (it might be affecting it, who knows).

You want to use the field name, not the ID, in the field search parameter. So in {exp:pro_search:results} use search:route_type="{pro_search_search:field_id_15}" (assuming that the EE field is called “route_type” and the search form field is called “search:field_id_15” but I’d name that form field “route_type” also, and then you could say search:route_type="{pro_search_route_type}".)

Lastly, a keyword search and a field search are different, and collections are ONLY used for keyword searches. So collection="all-jobs" is not necessary in your case – you want channel="all-jobs"

And maybe that’ll work? Watch out for curly quotes.

       
VincentWoodard's avatar
VincentWoodard
2 posts
6 months ago
VincentWoodard's avatar VincentWoodard

I got it! Thank admin

VincentWoodard (space waves free)

       
DylanWalker's avatar
DylanWalker
2 posts
one month ago
DylanWalker's avatar DylanWalker

@paper minecraft Great. Easy understand.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.