Bitrix Site Manager

Filters

A majority of functions and methods of the Information Blocks module, namely those used to retrieve lists, allow using different filters to specify search conditions. The filter type operators are specified right before the name of the filter field.

Types

  • (empty) - for the string fields denotes search using a mask (the mask notation: "%" - any number of arbitrary symbols; "_" - any one symbol). For fields of non-string types, this means strict match searching.
    
    <?
    // find elements whose name starts from "#"
    $res = CIBlockElement::GetList(Array(), Array("NAME"=>"#%"));
    
    // find elements with the ID == 100
    $res = CIBlockElement::GetList(Array(), Array("ID"=>"100"));
    ?>
  • "!" - for the string fields denotes expression that does not match a mask, or not equal for other types.
    
    <?
    // find elements whose name does not start with "#"
    $res = CIBlockElement::GetList(Array(), Array("!NAME"=>"#%"));
    ?>
  • "?" - means the logic is used:
    
    <?
    // find elements whose name contains "One" or "Two"
    $res = CIBlockElement::GetList(Array(), Array("?NAME"=>"One | Two"));
    ?>
  • "<" - less
  • "<=" - less or equal
  • ">" - more
  • ">=" - more or equal
    
    <?
    // find elements whose name starts with "A"
    $res = CIBlockElement::GetList(Array(), 
                                   Array(">=NAME"=>"A", "<NAME"=>"B"));
    
    // find elements whose ID is more than 100
    $res = CIBlockElement::GetList(Array(), Array(">ID"=>"100"));
    ?>
  • "=" - equal
  • "!=" - not equal:
    
    <?
    // find elements whose name is "ELEMENT%1"
    $res = CIBlockElement::GetList(Array(), Array("=NAME"=>"ELEMENT%1"));
    ?>
  • "%" - substring,
  • "!%" - not substring:
    
    <?
    // find elements whose name contains the symbol "%"
    $res = CIBlockElement::GetList(Array(), Array("%NAME"=>"%"));
    ?>
  • "<>" - between,
  • "!<>" - not between. These filters takes an array in the format Array("lower bound of a range", "higher bound of a range") on input:
    
    <?
    // find elements whose name starts 
    // between "A" and "B" or between "D" and "E"
    $res = CIBlockElement::GetList(Array(), 
                                   Array("><NAME"=>Array(Array("A", "B"), 
                                                         Array("D", "E"))));
    
    // find elements whose active state 
    // date is not within 2003
    $res = CIBlockElement::GetList(Array(), Array("!><DATE_ACTIVE_FROM"=>
    	Array(
    		date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), 
                       mktime(0,0,0,1,1,2003)),
    		date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), 
                       mktime(0,0,0,1,1,2004))
    	)));
    ?>