Views: 1354
Last Modified: 24.11.2023
Objective
Select an element property/properties and display in on the screen.
Solution
First stage of the objective is simple: method GetProperty of class CIBlockElement is detailed in the documentation.
Second stage. Take the property HTML\text. Its value cannot be just printed (key VALUE
), because its an array, containing "raw" value and its type (HTML or text). Requires a single method call: GetDisplayValue of class CIBlockFormatProperties:
$arResult['DISPLAY_PROPERTIES'][$pid] = CIBlockFormatProperties::GetDisplayValue($arResult, $prop);
Now, we can write as follows in the template:
echo $arResult['DISPLAY_PROPERTIES'][$pid]['DISPLAY_VALUE'];
And any property, which type presupposes a value formatting before display - will be converted accordingly.