M
M
Maxim Morozov2020-04-23 15:57:47
PHP
Maxim Morozov, 2020-04-23 15:57:47

How (in a template) using PHP to hide the Bitrix property if it is empty?

This is how I display the "Bitrix" property in the template:

<div class="article iblock" <?if($arResult['SHOW_OFFERS_PROPS']){?>id="<? echo $arItemIDs["ALL_ITEM_IDS"]['DISPLAY_PROP_ARTICLE_DIV'] ?><?}?>>
<span class="far fa-info-circle" style="font-size: 16px; color: #999;"></span>&nbsp;
<span class="block_title" itemprop="name"><?=$arResult["PROPERTIES"]["CML2_ARTICLE"]["NAME"];?>:</span>
<span class="value" itemprop="value"><?=$arResult["PROPERTIES"]["CML2_ARTICLE"]["VALUE"]?></span>
</div>

How to properly hide the whole if CML2_ARTICLE is an empty value. I think that I need to assign a class, but I can’t do it right, because I’m not very friendly with php yet ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2020-04-23
@morozoffmaks

<div class="article iblock" <?if($arResult['SHOW_OFFERS_PROPS']){?>id="<? echo $arItemIDs["ALL_ITEM_IDS"]['DISPLAY_PROP_ARTICLE_DIV'] ?><?}?>>
<span class="far fa-info-circle" style="font-size: 16px; color: #999;"></span>&nbsp;
<? if (!empty($arResult["PROPERTIES"]["CML2_ARTICLE"]["VALUE"])){?>
<span class="block_title" itemprop="name"><?=$arResult["PROPERTIES"]["CML2_ARTICLE"]["NAME"];?>:</span>
<span class="value" itemprop="value"><?=$arResult["PROPERTIES"]["CML2_ARTICLE"]["VALUE"]?></span>
<?}?>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question