Answer the question
In order to leave comments, you need to log in
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"] != " " && $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);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question