A
A
Anto2021-01-31 13:08:10
1C-Bitrix
Anto, 2021-01-31 13:08:10

How to set up the filter?

Good afternoon!
Please help, there is a filter on the page, it filters the news, and when searching by the "Type" parameter, the filter first displays an empty sheet with the text "what is not found", and on the second page the already found information. But the filter works this way only for two properties of the Type parameter, for the rest it displays correctly on the first page. The information is displayed in a customized news.list component.

The component has such added code. which filters by the Type property,

/*----- Сортировка по типу -----*/
$section = [];
foreach($_GET['toursFilter_pf']['TYPE'] as $k => $s){
  $section[$k] = true;
}

foreach($arResult['ITEMS'] as $k => &$arItem) {
  $unset = true;
  foreach($arItem['PROPERTIES']['TYPE']['VALUE'] as $v){
    if(isset($section[$v]) || count($section) == 0){
      $unset = false;
    }
  }
  if($unset){
    unset($arResult['ITEMS'][$k]);
  }
}
unset($arItem);

The component itself with the template https://yadi.sk/d/qO187h-oWhggKw

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question