Answer the question
In order to leave comments, you need to log in
Extra items in search results?
There is a loop that displays the elements of the search results
<?foreach($arResult['SEARCH'] as $arItem):?>
<div class="news-item">
<?
$arFilter = Array("IBLOCK_ID"=>$arItem[15], "ID"=>$arItem["ITEM_ID"], "PROPERTY_FILIAL" => $filial,);
$res = CIBlockElement::GetList(Array(), $arFilter);
if ($ob = $res->GetNextElement()){;
$arFields = $ob->GetFields(); // поля элемента
$arProps = $ob->GetProperties(); // свойства элемента
}
?>
<?php if ($filial == $arProps['FILIAL']['VALUE']) {
echo ' <a class="service__link" href="">'.$arFields2['NAME'].'</a>
<p class="service__field">'.$arProps['EMPTY']['VALUE'].'</p>
<p class="service__field">'.$arProps['NDS']['VALUE'].'</p>
<p class="service__field">'.$arProps['FILIAL']['VALUE'].'</p>';
} else {
echo '';
} ?>
</div>
<?endforeach;?>
Answer the question
In order to leave comments, you need to log in
On index.php with a call to the search.page component
1. In the parameter of the FILTER_NAME component, for example, write
2. Before calling the component, add the code
"FILTER_NAME" => "searchFilter"
$itemIds = [];
// здесь укажи ИД своего инфоблока (или массив инфоблоков)
$iblockId = 1;
// здесь значение из get (я наугад написал filial)
$filial = $_GET['filial'];
$iterator = \CIBlockElement::GetList([], ['IBLOCK_ID' => $iblockId, 'PROPERTY_FILIAL' => $filial], false, false, ['ID']);
while($row = $iterator->Fetch()) {
$itemIds[] = $row['ID'];
}
$GLOBALS['searchFilter'] = ['ITEM_ID' => $itemIds];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question