V
V
VlasT2021-02-25 10:52:05
1C-Bitrix
VlasT, 2021-02-25 10:52:05

Filtering fields in the Highload block?

Good afternoon! on the site it was required to display the filtering of the country, regions and cities in the select fields. Brought it out like this.

<?

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;

CModule::IncludeModule('iblock');
CModule::IncludeModule('highloadblock');

   $hlblock = HL\HighloadBlockTable::getById(4)->fetch(); // id highload блока
   $entity = HL\HighloadBlockTable::compileEntity($hlblock);
   $entityClass = $entity->getDataClass();

   $res = $entityClass::getList(array(
       'select' => array('*'),
       //'order' => array('ID' => 'ASC'),
   ));
   $regions = [];
   $gorods = [];
   $strana = [];
while($row = $res->fetch()) {
    $row = $res->fetch();


    if($row['UF_REGION'] != '')
        $regions[] = $row["UF_REGION"];
    if($row['UF_GOROD'] != '')
        $gorods[] = $row["UF_GOROD"];
    if($row['UF_STRANA'] != '')
     $strana[] = $row["UF_STRANA"];
}

if (!empty($arResult['ERROR']))
{
  echo $arResult['ERROR'];
  return false;
}

$GLOBALS['APPLICATION']->SetAdditionalCSS('/bitrix/js/highloadblock/css/highloadblock.css');

//$GLOBALS['APPLICATION']->SetTitle('Highloadblock List');

$aCity = array();

foreach($arResult["rows"] as $arElement){

if(!isset($aCity[$arElement["UF_GOROD"]])  && $arElement["UF_GOROD"] != ""  && $arElement["UF_GOROD"] != "&nbsp;" && $arElement["UF_VYGRUZHATNASAYT"]=="да" ){

$aCity[$arElement["UF_GOROD"]] = $arElement["UF_GOROD"];

}
}

sort($aCity);
$gorods = array_unique($gorods);
$regions = array_unique($regions);
$strana = array_unique($strana);
sort($gorods);
sort($regions);
sort($strana);
?>


Tell me how to add filtering. So that when choosing a Country, regions and cities of other countries are excluded from other lists.

Similarly, when choosing a region. to exclude cities from another region when selecting.

I'm sorry, maybe I'm expressing myself incorrectly. Ready to fix everything

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