MODX Community

Migx Search and filter in tables

I am building a Second Hand Cars and Bikes selling website and I am using MIGX with custom Database Tables for fields like car/bike color, year of purchase, model etc. Everything is smooth and easy to display on front end. But client want visitors to search and filter fields. Like on Cars page, there is a search and filter area where there is drop down/multi select boxes from which visitors can select and filter cars based on fields like colors, models etc. can anyone suggest me how to make this search and filter capability with Migx ?

Here is an example wordpress site which shows exactly what I am trying to build in Modx with Migx. (Check Left sidebar)
Thanks :slight_smile:

On the frontend: Add some GET or POST parameters to your request.

In MODX: Read the values of the parameters in a snippet.
Then use these values when you query your database.

If you are using migxLoopCollection then add a where-property:

[[!migxLoopCollection? ... &where=`{"color":"[[!+color_param]]"}`]]

If you are using getCollection then add a where-condition to your query:

$c = $modx->newQuery('Car');
   'color' => $color_param
$cars = $modx->getCollection('Car',$c);

If you have pdotools installed you can use it like this:
[[!migxLoopCollection? … &where={"color":"[[#REQUEST.carspot_layout_type]]"}]]


It’s been a while since we’ve seen dimmy — their last post was 5 months ago.

Its good to see you back !! And I am gonna try this and will get back to you!

Thank you! I am going to try this first. :wink: I will post my solution here also.