J
J
Julia2021-10-12 14:19:16
1C-Bitrix
Julia, 2021-10-12 14:19:16

How to display a specific custom field in news.list?

Good afternoon! I got a problem. The page has a news component with custom fields (SUB_HEADER and PRICE).

If the fields are displayed in a cycle, then they are displayed in both news.list and news.detail, I display them like this:

<?foreach($arItem["DISPLAY_PROPERTIES"] as $pid=>$arProperty):?> 
            <?=$arProperty["NAME"]?>:              
<?if(is_array($arProperty["DISPLAY_VALUE"])):?>
                 <?=implode(" / ", $arProperty["DISPLAY_VALUE"]);?>             
<?else:?>                
 <?=$arProperty["DISPLAY_VALUE"];?>             
<?endif?>             
<br />         <?endforeach;?>

If I try to display one of the properties (namely, this is what I need), then it is displayed in news.detail, and is not displayed in news.list, here is the code:

<?if(!empty($arResult["DISPLAY_PROPERTIES"]["SUB_HEADER"]["VALUE"])):?>
    <?=$arResult["DISPLAY_PROPERTIES"]["SUB_HEADER"]["VALUE"]?>
                   <?endif;?>

Where could be the problem? I'm confused. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rucklless, 2021-10-12
@jkhvat

if the bottom code is from news.list then why is there $arResult and not $arItem? As in the top version. In the same place $arResult in foreach gets over as $arItem.
If I remember it right...

<?if(!empty($arItem["DISPLAY_PROPERTIES"]["SUB_HEADER"]["VALUE"])):?>
    <?=$arItem["DISPLAY_PROPERTIES"]["SUB_HEADER"]["VALUE"]?>
                   <?endif;?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question