R
R
ragnar_ok2019-02-22 18:21:54
1C-Bitrix
ragnar_ok, 2019-02-22 18:21:54

How to correctly display the custom property of an infoblock?

How to correctly display one custom property of an infoblock?
I create a custom property of the PROPERTY infoblock.
I'm calling the component. I specify the $arParams key with the value - the character code of the custom property.

<?$APPLICATION->IncludeComponent(
  "bitrix:news",
  "",
  Array(
                 ... ,
   		"PROPERTY_CODE_PROPERTY" => "PROPERTY",
  )
);?>

I customize the template. I check the custom property at the beginning of template.php:
<?if(array_key_exists('PROPERTY_CODE_PROPERTY', $arParams)):?>
    <?$PROPERTY = $arParams["PROPERTY_CODE_PROPERTY"]?>
<?else:?>
    <?exit?>
<?endif?>

I call a custom property:
<?if(
   array_key_exists($PROPERTY, $arResult["PROPERTIES"]["PROPERTY"]["VALUE"])
   && !empty($arResult["PROPERTIES"]["PROPERTY"]["VALUE"])
):?>
    <?=$arResult["PROPERTIES"]["PROPERTY"]["VALUE"]?>
<?endif?>

Am I checking correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2019-02-23
@jasper-blondin

"PROPERTY_CODE_PROPERTY" => "PROPERTY",

Where did you see it? What is it anyway?
There is also official documentation: https://dev.1c-bitrix.ru/user_help/components/cont...
Depending on where you are going to display the property (in the list or on the detailed page), you must use the appropriate key:
"LIST_PROPERTY_CODE" => Array("MY_PROPERTY"),
"DETAIL_PROPERTY_CODE" => Array("MY_PROPERTY"),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question