J
J
jorshjorsh952018-09-04 12:49:19
1C-Bitrix
jorshjorsh95, 2018-09-04 12:49:19

Why does the exception in arrFilter not work?

Good afternoon, there is a condition:

if($_POST['SECTION_ID'] != 4){
    $arrFilter["!SECTION_ID"][] = 4;
  }
  if($_POST['SECTION_ID'] != 27){
    $arrFilter["!SECTION_ID"][] = 27;
  }
  if($_POST['SECTION_ID'] != 3){
    $arrFilter["!SECTION_ID"][] = 3;
  }
  if($_POST['SECTION_ID'] != 2){
    $arrFilter["!SECTION_ID"][] = 2;
  }

BUT, it does not exclude sections from the CIBlockElement::GetList selection, if one section is left in the exclusion:
if($_POST['SECTION_ID'] != 4){
    $arrFilter["!SECTION_ID"] = 27;
  }

, then everything works
On the Bitrix forum I found this option:
if($_POST['SECTION_ID'] != 4){
    $arrFilter[0]["!SECTION_ID"][] = 27;
  }
  if($_POST['SECTION_ID'] != 27){
    $arrFilter[0]["!SECTION_ID"][] = 27;
  }
  if($_POST['SECTION_ID'] != 3){
    $arrFilter[0]["!SECTION_ID"][] = 3;
  }
  if($_POST['SECTION_ID'] != 2){
    $arrFilter[0]["!SECTION_ID"][] = 2;
  }

Instead of SECTION_ID, I tried IBLOCK_SECTION_ID, filtering does not work there at all
. Please tell me why, and how to deal with it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Emelyanov, 2018-09-04
@babarun

The negation in the SECTION_ID filter will not work if the elements are bound to multiple sections, in case of filtering by an array of IDs.

A
Alexander, 2018-09-06
Madzhugin @Suntechnic

> I found this option on the Bitrix forum:
Maybe they offered something like this:
if($_POST['SECTION_ID'] != 27){
$arrFilter[0]["!SECTION_ID"] = 27;
}
if($_POST['SECTION_ID'] != 3){
$arrFilter[1]["!SECTION_ID"] = 3;
}
?
Honestly, it's not clear what you are trying to achieve with this code. And the code itself is scary, sorry...
If you have such a construct in the if(cond1){} if(cond2){} code, you are most likely doing something wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question