Answer the question
In order to leave comments, you need to log in
BItrix how not to display an element if the value in the array is empty?
There is a page on which cities and vacancies are displayed.
Array by which cities are displayed:
How to make it so that elements in which the value "U_VACANCY_CNT" is empty are not displayed (for example, in the screenshot the last element contains an empty U_VACANCY_CNT )?
output component itself:
$rsCities = CIBlockElement::GetList(
array('SORT' => 'ASC', 'NAME' => 'ASC'),
array(
'IBLOCK_ID' => 7,
'ACTIVE' => 'Y',
),
false,
false,
array('ID', 'NAME', 'CODE', 'IBLOCK_SECTION_ID')
);
while($arCity = $rsCities->Fetch()) {
$arCity['U_VACANCY_CNT'] = $vacanciesGroupedByCity[$arCity['CODE']];
if($arResult['ITEMS'][$arCity['IBLOCK_SECTION_ID']]) {
$arResult['ITEMS'][$arCity['IBLOCK_SECTION_ID']]['ITEMS'][] = $arCity;
}
}
Answer the question
In order to leave comments, you need to log in
while($arCity = $rsCities->Fetch())
if (!empty($arCity['U_VACANCY_CNT'] ))
{
$arCity['U_VACANCY_CNT'] = $vacanciesGroupedByCity[$arCity['CODE']];
if($arResult['ITEMS'][$arCity['IBLOCK_SECTION_ID']]) {
$arResult['ITEMS'][$arCity['IBLOCK_SECTION_ID']]['ITEMS'][] = $arCity;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question