Documentation

Block filter conversion

Description

Recommended block filter format

The following classes are used for converting a block filter (when recommendations are followed) to other formats:

FIrst, you need to describe all filter fields for conversion. Each field is described as follows:

  • id - field ID. Matches with the 'key' field for condition from block filter
  • type - field type. Possible values:
    • string - string
    • number - number
    • date - date
    • custom_date - date ranges
    • list - list/multiple list for selection
    • checkbox - checkbox (selected/not selected)
    • dest_selector - selection for binding to entity
  • operators - array for prefixes to generate ORM filter (see \Bitrix\Landing\Source\DataFilter)

You can indicate a multiplicity attribute for list fields:

params => [
         'multiple' => 'Y'
      ]

For date fields you can allow to select time:

time => true;

Keys for fields array are field IDs.

Example of filter description

$fields = [];
   // NAME field of string type
   $fields['NAME'] = [
      'id' => 'NAME', // identifier (matches with array key)
      'type' => 'string', // String field type (main.ui.filter)
   ];
   // ID field of number type
   $fields['ID'] = [
      'id' => 'ID', // identifier (matches with array key)
      'type' => 'number', // Number field type (main.ui.filter)
   ];
   // ENTITY_LIST field of list type
   $fields['ENTITY_LIST'] = [
      'id' => 'ENTITY_LIST', // identifier (matches with array key)
      'type' => 'list', // List field type (main.ui.filter)
      'params' => [ // parameters
         'multiple' => 'Y' // multiple selection
      ]
   ];
   // ACTIVE field of checkbox type
   $fields['ACTIVE'] = [
      'id' => 'ACTIVE', // identifier (matches with array key)
      'type' => 'checkbox', Checkbox type field (main.ui.filter)
      'operators' => [ // prefixes for conditions
         'default' => '' // prefix by default
      ]
   ];

© «Bitrix24», 2001-2024
Up