E
E
exxgamer2018-10-29 15:41:13
1C-Bitrix
exxgamer, 2018-10-29 15:41:13

How to display a custom property for a Bitrix section?

It is necessary to display a custom property in the Bitrix section. There is an approximate code that can possibly be completed and everything will work as it should.

<? 
    $rsResult = CIBlockSection::GetList(array("SORT"=>"ASC"), array("IBLOCK_ID"=>"1"), false, array("UF_HEADH1"));
while($arResult = $rsResult->GetNext())
{
echo $arResult[UF_HEADH1]; }
?>

So he pulls out all the properties and later gets the one I need, only without filtering by section. Conditionally, the field is filled in for two sections ("hello" for one and "bye for the other). So the code on all pages of all sections will display "hello bye" for me. I need to somehow filter by the code of the current section so that the corresponding text is displayed in it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Nikolaev, 2018-10-29
@gromdron

Well, you filter by IBLOCK_ID, what prevents you from filtering by the section code or by its ID?

$select = [
  "UF_HEADH1"
  
];

$sort = [
  "SORT" => "ASC"
];

$filter = [
  /* @var int ID инфоблока */
  'IBLOCK_ID' => 1,

  /* @var string Символьный код раздела */
  'CODE' => 'SECTION_CODE',

  /* @var int ID раздела */
  'ID' => 123,
];

$rsResult = CIBlockSection::GetList(
  $sort,
  $filter,
  false,
  $select
);
while($arResult = $rsResult->GetNext())
{
  echo $arResult['UF_HEADH1'];
}

A
Andrews32, 2019-11-27
@Andrews32

Gentlemen, how to display the custom property of the PRODUCT (in the catalog section, in the product card)?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question