Answer the question
In order to leave comments, you need to log in
How to display selected additional fields for different sections in Bitrix?
Hello. On the site , you need to display the selected unique values from the additional fields (Tags) of the sections (type - Binding to infoblock sections)
<div class="tags_cloud"><?
//$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => "5"), false, $arSelect = array("UF_TAGI"));
$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ID" =>$arResult["SECTION"]["ID"]), false, $arSelect = array("UF_TAGI"));
if($arSection = $rsResult -> GetNext())
{
$uftag = $arSection["UF_TAGI"];
$ufcategory = $arSection["UF_CATEGORY"];
if($uftag) {
$arFilter = array('IBLOCK_ID' => 27,'ID' => $uftag);
$rsItems = CIBlockSection::GetList(array(),$arFilter);
echo '<div class="catalog-tags">';
while ($arItem = $rsItems->GetNext())
{
echo '<div class="catalog-tags-item"><a href="'.$arItem['SECTION_PAGE_URL'].'">'.$arItem["NAME"].'</a></div>';
}
echo '</div>';
}
if($ufcategory) {
$arFilter = array('IBLOCK_ID' => 27,'ID' => $ufcategory);
$rsItems = CIBlockSection::GetList(array(),$arFilter);
echo '<div class="catalog-list-cat">';
while ($arItem = $rsItems->GetNext())
{
echo '<div class="class="catalog-tags-item""><a href="'.$arItem['SECTION_PAGE_URL'].'">'.$arItem["NAME"].'</a></div>';
}
echo '</div>';
}
}
?></div>
Answer the question
In order to leave comments, you need to log in
Amendment. The solution has been found!
In catalog.section.list and clear the cache
<? //Блок вывода Доп полей в разделах
$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ID" =>$arResult["SECTION"]["ID"]), false, $arSelect = array("UF_TAGI"));
if($arSection = $rsResult -> GetNext())
{
$uftag = $arSection["UF_TAGI"];
if($uftag) {
$arFilter = array('IBLOCK_ID' => 27,'ID' => $uftag);
$rsItems = CIBlockSection::GetList(array(),$arFilter);
echo '<div class="catalog-tags">';
while ($arItem = $rsItems->GetNext())
{
echo '<div class="catalog-tags-item"><a href="'.$arItem['SECTION_PAGE_URL'].'">'.$arItem["NAME"].'</a></div>';
}
echo '</div>';
}
}
?>
<?
$IBLOCK_ID = 27; // ID нужного инфоблока
//Получаем все возможные поля текущего пользователя
$rsUser = CUser::GetByID($USER->GetID());
$arUser = $rsUser->Fetch();
//Выводим если множественное
foreach ($arUser['UF_TAGI'] as $propertyUf):
echo $propertyUf;
endforeach;
//Создаем массив фильтра
$arFilter = array('IBLOCK_ID' => $IBLOCK_ID, 'ACTIVE' => 'Y');
//Добавляем наш массив в котором перечислены ID разделов выбранные пользователем
$sect_id = $fofilter;
//Создаем массив фильтра. В конце переменная фильтра
$arFilter = array('IBLOCK_ID' => $IBLOCK_ID, 'ACTIVE' => 'Y', 'ID' => $sect_id);
//Создаем массив выводимых полей
$arSelect = array('ID', 'NAME');
//Применяем метод с фильтром и полями
$rsSection = CIBlockSection::GetTreeList($arFilter, $arSelect);
//Выводим названия разделов
while ($arSection = $rsSection->Fetch()) {
echo $arSection['NAME'];
}
foreach ($arUser['UF_TAGI'] as $propertyUf):
$sectionsUser .= '\'' . $propertyUf . '\',';
endforeach;
eval('$fofilter=array(' . $sectionsUser . ');');
extract($fofilter);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question