S
S
Sergey2020-01-15 11:50:04
MODX
Sergey, 2020-01-15 11:50:04

How to filter by field (multiple choice)?

I don't understand how to make such a request. Resources have a "multiple choice" field, where the type of fuel "Gasoline", "Diesel" is selected. There is also a multiple choice in the filter on the site (with checkboxes) Gasoline Diesel
If a person selects Gasoline and Diesel in the filter, you need to display the results of who in the admin panel is selected in the list (multiple) Gasoline, Diesel, Gasoline and Diesel
If in the admin panel there is a single list everything is simple

if(isset($_GET['fuel_type']) && !empty($_GET['fuel_type'])) {
  $where[] = 'fuel_type IN (' . implode(',', $_GET['fuel_type']) . ')';	
}

But I don’t understand how to do with the plural

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2020-01-15
@an-tar

Have you seen how the value of such a field is stored in the admin panel? Look, I think it will immediately become clear what request to write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question