Answer the question
In order to leave comments, you need to log in
How to get the value of an element property by ID in Bitrix?
There is an infoblock with ID 5 .
It has an element with ID 371 .
You need to get the values of the slogan and copy properties .
The data will be displayed in the footer of the site, in the footer.php file.
The following construction does not output anything:
<?
$res = CIBlockElement::GetByID($_GET["371"]);
if($ar_res = $res->GetNext())
echo $ar_res['PROPERTIES']['slogan']['VALUE'];
echo $ar_res['PROPERTIES']['copy']['VALUE'];
?>
Answer the question
In order to leave comments, you need to log in
The GetByID method does not return the element's properties, but is a simple getList layer that queries all the properties.
Explicitly use CIblockElement::getList to get properties
$resElement = \CIBlockElement::GetList(
[],
[
'IBLOCK_ID' => 5,
'ID' => 371,
],
false,
false,
[
'ID',
'IBLOCK_ID',
'PROPERTY_SLOGAN',
'PROPERTY_COPY'
]
);
if ( !($element = $resElement->getNext() ) )
{
echo "Элемент не найден";
return;
}
var_dump($element);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question