Answer the question
In order to leave comments, you need to log in
Displaying product characteristics in the Bitrix announcement?
Good afternoon. Please help me understand the code.
Here, the characteristics of the product in the announcement are displayed, to the right of the photo. It is necessary to display the first three. Here is the code:
<?if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED!==true) die();?>
<table class="bxr-props-table">
<?foreach($arParams["PREVIEW_DETAIL_PROPERTY_CODE"] as $propertyCode):
$arProperty = $arResult["DISPLAY_PROPERTIES"][$propertyCode];
if (!is_array($arProperty["DISPLAY_VALUE"]) && $arProperty["DISPLAY_VALUE"]) {?>
<tr itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
<td class="bxr-props-name"><span itemprop="name"><?=$arProperty["NAME"]?></span></td>
<td class="bxr-props-data"><span itemprop="value"><?=$arProperty["DISPLAY_VALUE"]?></span></td>
</tr>
<?} elseif (is_array($arProperty["DISPLAY_VALUE"]) && count($arProperty["DISPLAY_VALUE"] > 0)) {
$withDesc = false;
foreach($arProperty["DESCRIPTION"] as $cell=>$val) {
if ($val) {
$withDesc = true;
break;
}
}
if ($withDesc) {?>
<tr>
<td colspan="2" class="bxr-props-data bxr-props-data-group">
<b><?=$arProperty["NAME"]?></b></td>
</tr>
<?foreach($arProperty["DISPLAY_VALUE"] as $cell=>$val){?>
<tr itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
<td class="bxr-props-name no-bold"><span itemprop="name"><?=$arProperty["DESCRIPTION"][$cell]?></span></td>
<td class="bxr-props-data"><span itemprop="value"><?=$val?></span></td>
</tr>
<?}
} else {?>
<tr itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
<td class="bxr-props-name"><span itemprop="name"><?=$arProperty["NAME"]?></span></td>
<td class="bxr-props-data"><span itemprop="value"><?= implode(', ', $arProperty["DISPLAY_VALUE"])?></span></td>
</tr>
<?}
}
if ($arParams["HIDE_PREVIEW_PROPS_INLIST"] == 'Y'):
unset($arResult["DISPLAY_PROPERTIES"][$propertyCode]);
endif;
endforeach;?>
</table>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question