RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 771521
Accepted
Егор Rmd
Егор Rmd
Asked:2020-01-16 20:40:37 +0000 UTC2020-01-16 20:40:37 +0000 UTC 2020-01-16 20:40:37 +0000 UTC

为什么图片标题不显示?(result_modifier.php)

  • 772

Bitrix 17.4 有用于 catalog.section 的 result_modifier.php

// Заменяем картинку у товара на дефолтную, у которой не задано изображение
 foreach($arResult["ITEMS"] as $key=>$arItem):
  if (!is_array($arItem["PREVIEW_PICTURE"])):
  $arResult["ITEMS"][$key]["PREVIEW_PICTURE"]["SRC"]=SITE_TEMPLATE_PATH."/assets/image/main/car-item-2.png";
  $arResult["ITEMS"][$key]["PREVIEW_PICTURE"]["HEIGHT"]=150;
  $arResult["ITEMS"][$key]["PREVIEW_PICTURE"]["WIDTH"]=150;  
  endif;
 endforeach;

但是代码不起作用,只显示手动上传的图片。可能是什么问题呢?输出中的图片通过如下属性加载:

在此处输入图像描述

也许应该有另一个常量而不是 PREVIEW_PICTURE。

组件本身的UPD1模板代码

<? if ( ! defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true ) {
    die();
}

use \Bitrix\Main\Localization\Loc;

/**
 * @global CMain $APPLICATION
 * @var array $arParams
 * @var array $arResult
 * @var CatalogSectionComponent $component
 * @var CBitrixComponentTemplate $this
 * @var string $templateName
 * @var string $componentPath
 */

$this->setFrameMode(true);
$this->addExternalCss('/bitrix/css/main/bootstrap.css');

if ( ! empty($arResult['NAV_RESULT']) ) {
    $navParams = array(
        'NavPageCount' => $arResult['NAV_RESULT']->NavPageCount,
        'NavPageNomer' => $arResult['NAV_RESULT']->NavPageNomer,
        'NavNum' => $arResult['NAV_RESULT']->NavNum
    );
} else {
    $navParams = array(
        'NavPageCount' => 1,
        'NavPageNomer' => 1,
        'NavNum' => $this->randString()
    );
}

$showTopPager = false;
$showBottomPager = false;
$showLazyLoad = false;

if ( $arParams['PAGE_ELEMENT_COUNT'] > 0 && $navParams['NavPageCount'] > 1 ) {
    $showTopPager = $arParams['DISPLAY_TOP_PAGER'];
    $showBottomPager = $arParams['DISPLAY_BOTTOM_PAGER'];
    $showLazyLoad = $arParams['LAZY_LOAD'] === 'Y' && $navParams['NavPageNomer'] != $navParams['NavPageCount'];
}

$templateLibrary = array('popup', 'ajax', 'fx');
$currencyList = '';

if ( ! empty($arResult['CURRENCIES']) ) {
    $templateLibrary[] = 'currency';
    $currencyList = CUtil::PhpToJSObject($arResult['CURRENCIES'], false, true, true);
}

$templateData = array(
    'TEMPLATE_THEME' => $arParams['TEMPLATE_THEME'],
    'TEMPLATE_LIBRARY' => $templateLibrary,
    'CURRENCIES' => $currencyList
);
unset($currencyList, $templateLibrary);

$elementEdit = CIBlock::GetArrayByID($arParams['IBLOCK_ID'], 'ELEMENT_EDIT');
$elementDelete = CIBlock::GetArrayByID($arParams['IBLOCK_ID'], 'ELEMENT_DELETE');
$elementDeleteParams = array('CONFIRM' => GetMessage('CT_BCS_TPL_ELEMENT_DELETE_CONFIRM'));

$positionClassMap = array(
    'left' => 'product-item-label-left',
    'center' => 'product-item-label-center',
    'right' => 'product-item-label-right',
    'bottom' => 'product-item-label-bottom',
    'middle' => 'product-item-label-middle',
    'top' => 'product-item-label-top'
);

$discountPositionClass = '';
if ( $arParams['SHOW_DISCOUNT_PERCENT'] === 'Y' && ! empty($arParams['DISCOUNT_PERCENT_POSITION']) ) {
    foreach (explode('-', $arParams['DISCOUNT_PERCENT_POSITION']) as $pos) {
        $discountPositionClass .= isset($positionClassMap[$pos]) ? ' ' . $positionClassMap[$pos] : '';
    }
}

$labelPositionClass = '';
if ( ! empty($arParams['LABEL_PROP_POSITION']) ) {
    foreach (explode('-', $arParams['LABEL_PROP_POSITION']) as $pos) {
        $labelPositionClass .= isset($positionClassMap[$pos]) ? ' ' . $positionClassMap[$pos] : '';
    }
}

$arParams['~MESS_BTN_BUY'] = $arParams['~MESS_BTN_BUY'] ?: Loc::getMessage('CT_BCS_TPL_MESS_BTN_BUY');
$arParams['~MESS_BTN_DETAIL'] = $arParams['~MESS_BTN_DETAIL'] ?: Loc::getMessage('CT_BCS_TPL_MESS_BTN_DETAIL');
$arParams['~MESS_BTN_COMPARE'] = $arParams['~MESS_BTN_COMPARE'] ?: Loc::getMessage('CT_BCS_TPL_MESS_BTN_COMPARE');
$arParams['~MESS_BTN_SUBSCRIBE'] = $arParams['~MESS_BTN_SUBSCRIBE'] ?: Loc::getMessage('CT_BCS_TPL_MESS_BTN_SUBSCRIBE');
$arParams['~MESS_BTN_ADD_TO_BASKET'] = $arParams['~MESS_BTN_ADD_TO_BASKET'] ?: Loc::getMessage('CT_BCS_TPL_MESS_BTN_ADD_TO_BASKET');
$arParams['~MESS_NOT_AVAILABLE'] = $arParams['~MESS_NOT_AVAILABLE'] ?: Loc::getMessage('CT_BCS_TPL_MESS_PRODUCT_NOT_AVAILABLE');
$arParams['~MESS_SHOW_MAX_QUANTITY'] = $arParams['~MESS_SHOW_MAX_QUANTITY'] ?: Loc::getMessage('CT_BCS_CATALOG_SHOW_MAX_QUANTITY');
$arParams['~MESS_RELATIVE_QUANTITY_MANY'] = $arParams['~MESS_RELATIVE_QUANTITY_MANY'] ?: Loc::getMessage('CT_BCS_CATALOG_RELATIVE_QUANTITY_MANY');
$arParams['~MESS_RELATIVE_QUANTITY_FEW'] = $arParams['~MESS_RELATIVE_QUANTITY_FEW'] ?: Loc::getMessage('CT_BCS_CATALOG_RELATIVE_QUANTITY_FEW');

$generalParams = array(
    'SHOW_DISCOUNT_PERCENT' => $arParams['SHOW_DISCOUNT_PERCENT'],
    'PRODUCT_DISPLAY_MODE' => $arParams['PRODUCT_DISPLAY_MODE'],
    'SHOW_MAX_QUANTITY' => $arParams['SHOW_MAX_QUANTITY'],
    'RELATIVE_QUANTITY_FACTOR' => $arParams['RELATIVE_QUANTITY_FACTOR'],
    'MESS_SHOW_MAX_QUANTITY' => $arParams['~MESS_SHOW_MAX_QUANTITY'],
    'MESS_RELATIVE_QUANTITY_MANY' => $arParams['~MESS_RELATIVE_QUANTITY_MANY'],
    'MESS_RELATIVE_QUANTITY_FEW' => $arParams['~MESS_RELATIVE_QUANTITY_FEW'],
    'SHOW_OLD_PRICE' => $arParams['SHOW_OLD_PRICE'],
    'USE_PRODUCT_QUANTITY' => $arParams['USE_PRODUCT_QUANTITY'],
    'PRODUCT_QUANTITY_VARIABLE' => $arParams['PRODUCT_QUANTITY_VARIABLE'],
    'ADD_TO_BASKET_ACTION' => $arParams['ADD_TO_BASKET_ACTION'],
    'ADD_PROPERTIES_TO_BASKET' => $arParams['ADD_PROPERTIES_TO_BASKET'],
    'PRODUCT_PROPS_VARIABLE' => $arParams['PRODUCT_PROPS_VARIABLE'],
    'SHOW_CLOSE_POPUP' => $arParams['SHOW_CLOSE_POPUP'],
    'DISPLAY_COMPARE' => $arParams['DISPLAY_COMPARE'],
    'COMPARE_PATH' => $arParams['COMPARE_PATH'],
    'COMPARE_NAME' => $arParams['COMPARE_NAME'],
    'PRODUCT_SUBSCRIPTION' => $arParams['PRODUCT_SUBSCRIPTION'],
    'PRODUCT_BLOCKS_ORDER' => $arParams['PRODUCT_BLOCKS_ORDER'],
    'LABEL_POSITION_CLASS' => $labelPositionClass,
    'DISCOUNT_POSITION_CLASS' => $discountPositionClass,
    'SLIDER_INTERVAL' => $arParams['SLIDER_INTERVAL'],
    'SLIDER_PROGRESS' => $arParams['SLIDER_PROGRESS'],
    '~BASKET_URL' => $arParams['~BASKET_URL'],
    '~ADD_URL_TEMPLATE' => $arResult['~ADD_URL_TEMPLATE'],
    '~BUY_URL_TEMPLATE' => $arResult['~BUY_URL_TEMPLATE'],
    '~COMPARE_URL_TEMPLATE' => $arResult['~COMPARE_URL_TEMPLATE'],
    '~COMPARE_DELETE_URL_TEMPLATE' => $arResult['~COMPARE_DELETE_URL_TEMPLATE'],
    'TEMPLATE_THEME' => $arParams['TEMPLATE_THEME'],
    'USE_ENHANCED_ECOMMERCE' => $arParams['USE_ENHANCED_ECOMMERCE'],
    'DATA_LAYER_NAME' => $arParams['DATA_LAYER_NAME'],
    'BRAND_PROPERTY' => $arParams['BRAND_PROPERTY'],
    'MESS_BTN_BUY' => $arParams['~MESS_BTN_BUY'],
    'MESS_BTN_DETAIL' => $arParams['~MESS_BTN_DETAIL'],
    'MESS_BTN_COMPARE' => $arParams['~MESS_BTN_COMPARE'],
    'MESS_BTN_SUBSCRIBE' => $arParams['~MESS_BTN_SUBSCRIBE'],
    'MESS_BTN_ADD_TO_BASKET' => $arParams['~MESS_BTN_ADD_TO_BASKET'],
    'MESS_NOT_AVAILABLE' => $arParams['~MESS_NOT_AVAILABLE']
);

$obName = 'ob' . preg_replace('/[^a-zA-Z0-9_]/', 'x', $this->GetEditAreaId($navParams['NavNum']));
$containerName = 'container-' . $navParams['NavNum'];

if ( $showTopPager ) {
    ?>
    <div data-pagination-num="<?= $navParams['NavNum'] ?>">
        <!-- pagination-container -->
        <?= $arResult['NAV_STRING'] ?>
        <!-- pagination-container -->
    </div>
    <?
}

if ( $arParams['HIDE_SECTION_DESCRIPTION'] !== 'Y' ) {
    ?>
    <div class="bx-section-desc bx-<?= $arParams['TEMPLATE_THEME'] ?>">
        <p class="bx-section-desc-post"><?= $arResult['DESCRIPTION'] ?></p>
    </div>
    <?
}
?>

<div class="col-product col-sm-12" data-entity="<?= $containerName ?>">
    <div class="row clearfix">
        <?
        if ( ! empty($arResult['ITEMS']) && ! empty($arResult['ITEM_ROWS']) ) {
            $areaIds = array();

            foreach ($arResult['ITEMS'] as $item) {
                $uniqueId = $item['ID'] . '_' . md5($this->randString() . $component->getAction());
                $areaIds[$item['ID']] = $this->GetEditAreaId($uniqueId);
                $this->AddEditAction($uniqueId, $item['EDIT_LINK'], $elementEdit);
                $this->AddDeleteAction($uniqueId, $item['DELETE_LINK'], $elementDelete, $elementDeleteParams);
            }
            ?>
            <!-- items-container -->
            <?
            foreach ($arResult['ITEM_ROWS'] as $rowData) {
                $rowItems = array_splice($arResult['ITEMS'], 0, $rowData['COUNT']);
                ?>
                <div class="row <?= $rowData['CLASS'] ?>" data-entity="items-row">
                    <?
                    switch ($rowData['VARIANT']) {
                        case 0:
                            ?>
                            <div class="col-xs-12 product-item-small-card">
                                <div class="row">
                                    <div class="col-xs-12 product-item-big-card">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <?
                                                $item = reset($rowItems);
                                                $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                    'RESULT' => array(
                                                        'ITEM' => $item,
                                                        'AREA_ID' => $areaIds[$item['ID']],
                                                        'TYPE' => $rowData['TYPE'],
                                                        'BIG_LABEL' => 'N',
                                                        'BIG_DISCOUNT_PERCENT' => 'N',
                                                        'BIG_BUTTONS' => 'N',
                                                        'SCALABLE' => 'N'
                                                    ),
                                                    'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                                ), $component, array('HIDE_ICONS' => 'Y'));
                                                ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?
                            break;

                        case 1:
                            ?>
                            <div class="col-xs-12 product-item-small-card">
                                <div class="row">
                                    <?
                                    foreach ($rowItems as $item) {
                                        ?>
                                        <div class="col-xs-6 product-item-big-card">
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <?
                                                    $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                        'RESULT' => array(
                                                            'ITEM' => $item,
                                                            'AREA_ID' => $areaIds[$item['ID']],
                                                            'TYPE' => $rowData['TYPE'],
                                                            'BIG_LABEL' => 'N',
                                                            'BIG_DISCOUNT_PERCENT' => 'N',
                                                            'BIG_BUTTONS' => 'N',
                                                            'SCALABLE' => 'N'
                                                        ),
                                                        'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                                    ), $component, array('HIDE_ICONS' => 'Y'));
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <?
                            break;

                        case 2:
                            ?>
                            <div class="col-xs-12 product-item-small-card">
                                <div class="row">
                                    <?
                                    foreach ($rowItems as $item) {
                                        ?>
                                        <div class="col-sm-4 product-item-big-card">
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <?
                                                    $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                        'RESULT' => array(
                                                            'ITEM' => $item,
                                                            'AREA_ID' => $areaIds[$item['ID']],
                                                            'TYPE' => $rowData['TYPE'],
                                                            'BIG_LABEL' => 'N',
                                                            'BIG_DISCOUNT_PERCENT' => 'N',
                                                            'BIG_BUTTONS' => 'Y',
                                                            'SCALABLE' => 'N'
                                                        ),
                                                        'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                                    ), $component, array('HIDE_ICONS' => 'Y'));
                                                    ?>
                                                </div>
                                            </div>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <?
                            break;

                        case 3:
                            ?>

                            <?
                            foreach ($rowItems as $item) {
                                ?>
                                <?php //echo var_dump($item); ?>
                                <div class="col-sm-6 col-md-4 col-lg-3">
                                    <div class="gallery-filter__product gallery-product mh_item">
                                        <?
                                        $APPLICATION->IncludeComponent('bitrix:catalog.item', 'masshin_item_new', array(
                                            'RESULT' => array(
                                                'ITEM' => $item,
                                                'AREA_ID' => $areaIds[$item['ID']],
                                                'TYPE' => $rowData['TYPE'],
                                                'BIG_LABEL' => 'N',
                                                'BIG_DISCOUNT_PERCENT' => 'N',
                                                'BIG_BUTTONS' => 'N',
                                                'SCALABLE' => 'N'
                                            ),
                                            'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                        ), $component, array('HIDE_ICONS' => 'Y'));
                                        ?>
                                    </div>
                                </div>
                                <?
                            }
                            ?><?
                            break;

                        case 4:
                            $rowItemsCount = count($rowItems);
                            ?>
                            <div class="col-sm-6 product-item-big-card">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?
                                        $item = array_shift($rowItems);
                                        $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                            'RESULT' => array(
                                                'ITEM' => $item,
                                                'AREA_ID' => $areaIds[$item['ID']],
                                                'TYPE' => $rowData['TYPE'],
                                                'BIG_LABEL' => 'N',
                                                'BIG_DISCOUNT_PERCENT' => 'N',
                                                'BIG_BUTTONS' => 'Y',
                                                'SCALABLE' => 'Y'
                                            ),
                                            'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                        ), $component, array('HIDE_ICONS' => 'Y'));
                                        unset($item);
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 product-item-small-card">
                                <div class="row">
                                    <?
                                    for ($i = 0; $i < $rowItemsCount - 1; $i++) {
                                        ?>
                                        <div class="col-xs-6">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $rowItems[$i],
                                                    'AREA_ID' => $areaIds[$rowItems[$i]['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N',
                                                    'SCALABLE' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$rowItems[$i]['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <?
                            break;

                        case 5:
                            $rowItemsCount = count($rowItems);
                            ?>
                            <div class="col-sm-6 product-item-small-card">
                                <div class="row">
                                    <?
                                    for ($i = 0; $i < $rowItemsCount - 1; $i++) {
                                        ?>
                                        <div class="col-xs-6">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $rowItems[$i],
                                                    'AREA_ID' => $areaIds[$rowItems[$i]['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N',
                                                    'SCALABLE' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$rowItems[$i]['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <div class="col-sm-6 product-item-big-card">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?
                                        $item = end($rowItems);
                                        $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                            'RESULT' => array(
                                                'ITEM' => $item,
                                                'AREA_ID' => $areaIds[$item['ID']],
                                                'TYPE' => $rowData['TYPE'],
                                                'BIG_LABEL' => 'N',
                                                'BIG_DISCOUNT_PERCENT' => 'N',
                                                'BIG_BUTTONS' => 'Y',
                                                'SCALABLE' => 'Y'
                                            ),
                                            'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                        ), $component, array('HIDE_ICONS' => 'Y'));
                                        unset($item);
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <?
                            break;

                        case 6:
                            ?>
                            <div class="col-xs-12 product-item-small-card">
                                <div class="row">
                                    <?
                                    foreach ($rowItems as $item) {
                                        ?>
                                        <div class="col-xs-6 col-sm-4 col-md-2">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $item,
                                                    'AREA_ID' => $areaIds[$item['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N',
                                                    'SCALABLE' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <?
                            break;

                        case 7:
                            $rowItemsCount = count($rowItems);
                            ?>
                            <div class="col-sm-6 product-item-big-card">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?
                                        $item = array_shift($rowItems);
                                        $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                            'RESULT' => array(
                                                'ITEM' => $item,
                                                'AREA_ID' => $areaIds[$item['ID']],
                                                'TYPE' => $rowData['TYPE'],
                                                'BIG_LABEL' => 'N',
                                                'BIG_DISCOUNT_PERCENT' => 'N',
                                                'BIG_BUTTONS' => 'Y',
                                                'SCALABLE' => 'Y'
                                            ),
                                            'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                        ), $component, array('HIDE_ICONS' => 'Y'));
                                        unset($item);
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 product-item-small-card">
                                <div class="row">
                                    <?
                                    for ($i = 0; $i < $rowItemsCount - 1; $i++) {
                                        ?>
                                        <div class="col-xs-6 col-md-4">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $rowItems[$i],
                                                    'AREA_ID' => $areaIds[$rowItems[$i]['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N',
                                                    'SCALABLE' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$rowItems[$i]['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <?
                            break;

                        case 8:
                            $rowItemsCount = count($rowItems);
                            ?>
                            <div class="col-sm-6 product-item-small-card">
                                <div class="row">
                                    <?
                                    for ($i = 0; $i < $rowItemsCount - 1; $i++) {
                                        ?>
                                        <div class="col-xs-6 col-md-4">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $rowItems[$i],
                                                    'AREA_ID' => $areaIds[$rowItems[$i]['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N',
                                                    'SCALABLE' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$rowItems[$i]['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>
                                </div>
                            </div>
                            <div class="col-sm-6 product-item-big-card">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?
                                        $item = end($rowItems);
                                        $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                            'RESULT' => array(
                                                'ITEM' => $item,
                                                'AREA_ID' => $areaIds[$item['ID']],
                                                'TYPE' => $rowData['TYPE'],
                                                'BIG_LABEL' => 'N',
                                                'BIG_DISCOUNT_PERCENT' => 'N',
                                                'BIG_BUTTONS' => 'Y',
                                                'SCALABLE' => 'Y'
                                            ),
                                            'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                        ), $component, array('HIDE_ICONS' => 'Y'));
                                        unset($item);
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <?
                            break;

                        case 9:
                            ?>
                            <div class="col-xs-12">
                                <div class="row">
                                    <?
                                    foreach ($rowItems as $item) {
                                        ?>
                                        <div class="col-xs-12 product-item-line-card">
                                            <?
                                            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(
                                                'RESULT' => array(
                                                    'ITEM' => $item,
                                                    'AREA_ID' => $areaIds[$item['ID']],
                                                    'TYPE' => $rowData['TYPE'],
                                                    'BIG_LABEL' => 'N',
                                                    'BIG_DISCOUNT_PERCENT' => 'N',
                                                    'BIG_BUTTONS' => 'N'
                                                ),
                                                'PARAMS' => $generalParams + array('SKU_PROPS' => $arResult['SKU_PROPS'][$item['IBLOCK_ID']])
                                            ), $component, array('HIDE_ICONS' => 'Y'));
                                            ?>
                                        </div>
                                        <?
                                    }
                                    ?>

                                </div>
                            </div>
                            <?
                            break;
                    }
                    ?>
                </div>
                <?
            }
            unset($generalParams, $rowItems);
            ?>
            <!-- items-container -->
            <?
        } else {
            // load css for bigData/deferred load
            $APPLICATION->IncludeComponent('bitrix:catalog.item', '', array(), $component, array('HIDE_ICONS' => 'Y'));
        }
        ?>
    </div>
</div>
<?
if ( $showLazyLoad ) {
    ?>
    <div class="row bx-<?= $arParams['TEMPLATE_THEME'] ?>">
        <div class="btn btn-default btn-lg center-block" style="margin: 15px;"
             data-use="show-more-<?= $navParams['NavNum'] ?>">
            <?= $arParams['MESS_BTN_LAZY_LOAD'] ?>
        </div>
    </div>
    <?
}

if ( $showBottomPager ) {
    ?>
    <div data-pagination-num="<?= $navParams['NavNum'] ?>">
        <!-- pagination-container -->
        <?= $arResult['NAV_STRING'] ?>
        <!-- pagination-container -->
    </div>
    <?
}

$signer = new \Bitrix\Main\Security\Sign\Signer;
$signedTemplate = $signer->sign($templateName, 'catalog.section');
$signedParams = $signer->sign(base64_encode(serialize($arResult['ORIGINAL_PARAMETERS'])), 'catalog.section');
?>
<script>
    BX.message({
        BTN_MESSAGE_BASKET_REDIRECT: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_BASKET_REDIRECT')?>',
        BASKET_URL: '<?=$arParams['BASKET_URL']?>',
        ADD_TO_BASKET_OK: '<?=GetMessageJS('ADD_TO_BASKET_OK')?>',
        TITLE_ERROR: '<?=GetMessageJS('CT_BCS_CATALOG_TITLE_ERROR')?>',
        TITLE_BASKET_PROPS: '<?=GetMessageJS('CT_BCS_CATALOG_TITLE_BASKET_PROPS')?>',
        TITLE_SUCCESSFUL: '<?=GetMessageJS('ADD_TO_BASKET_OK')?>',
        BASKET_UNKNOWN_ERROR: '<?=GetMessageJS('CT_BCS_CATALOG_BASKET_UNKNOWN_ERROR')?>',
        BTN_MESSAGE_SEND_PROPS: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_SEND_PROPS')?>',
        BTN_MESSAGE_CLOSE: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_CLOSE')?>',
        BTN_MESSAGE_CLOSE_POPUP: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_CLOSE_POPUP')?>',
        COMPARE_MESSAGE_OK: '<?=GetMessageJS('CT_BCS_CATALOG_MESS_COMPARE_OK')?>',
        COMPARE_UNKNOWN_ERROR: '<?=GetMessageJS('CT_BCS_CATALOG_MESS_COMPARE_UNKNOWN_ERROR')?>',
        COMPARE_TITLE: '<?=GetMessageJS('CT_BCS_CATALOG_MESS_COMPARE_TITLE')?>',
        PRICE_TOTAL_PREFIX: '<?=GetMessageJS('CT_BCS_CATALOG_PRICE_TOTAL_PREFIX')?>',
        RELATIVE_QUANTITY_MANY: '<?=CUtil::JSEscape($arParams['MESS_RELATIVE_QUANTITY_MANY'])?>',
        RELATIVE_QUANTITY_FEW: '<?=CUtil::JSEscape($arParams['MESS_RELATIVE_QUANTITY_FEW'])?>',
        BTN_MESSAGE_COMPARE_REDIRECT: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_COMPARE_REDIRECT')?>',
        BTN_MESSAGE_LAZY_LOAD: '<?=$arParams['MESS_BTN_LAZY_LOAD']?>',
        BTN_MESSAGE_LAZY_LOAD_WAITER: '<?=GetMessageJS('CT_BCS_CATALOG_BTN_MESSAGE_LAZY_LOAD_WAITER')?>',
        SITE_ID: '<?=SITE_ID?>'
    });
    var <?=$obName?> =
    new JCCatalogSectionComponent({
        siteId: '<?=CUtil::JSEscape(SITE_ID)?>',
        componentPath: '<?=CUtil::JSEscape($componentPath)?>',
        navParams: <?=CUtil::PhpToJSObject($navParams)?>,
        deferredLoad: false, // enable it for deferred load
        initiallyShowHeader: '<?=! empty($arResult['ITEM_ROWS'])?>',
        bigData: <?=CUtil::PhpToJSObject($arResult['BIG_DATA'])?>,
        lazyLoad: !!'<?=$showLazyLoad?>',
        loadOnScroll: !!'<?=($arParams['LOAD_ON_SCROLL'] === 'Y')?>',
        template: '<?=CUtil::JSEscape($signedTemplate)?>',
        ajaxId: '<?=CUtil::JSEscape($arParams['AJAX_ID'])?>',
        parameters: '<?=CUtil::JSEscape($signedParams)?>',
        container: '<?=$containerName?>'
    });
</script>

UPD2

以下是 template.php 中负责显示项目图像的位置 (bitrix/cataog.item/mashine_item/card)

$idFirstImg = $item['PROPERTIES']['images']['VALUE']['0'];
$URL = CFile::GetPath($idFirstImg);

?>
<div class="gallery-product__boximg">
    <a href="<?= $URL ?>">
        <img src="<?= $URL ?>" alt="" class="gallery-product__img">
    </a>
</div>

前面是通过元素代码定义的,如下所示:

img src= (unknown) alt="" class="gallery-product__img"

php
  • 3 3 个回答
  • 10 Views

3 个回答

  • Voted
  1. Evgeniy Domatskiy
    2020-01-17T15:40:46Z2020-01-17T15:40:46Z

    в приведенном выше шаблоне компонента нет вывода картинки. Значение PREVIEW_PICTURE необходимо проверять в result_modifier.php компонента bitrix:catalog.item, который и выводит информацию о товаре.

    • 1
  2. Best Answer
    Егор Rmd
    2020-01-23T15:47:37Z2020-01-23T15:47:37Z

    Проще все решилось , посмотрел как реализовано по дефолту в
    bitrix/components/bitrix/catalog/item/templates/default/card/template.php

      <span class="product-item-image-original" id="<?=$itemIds['PICT']?>"
    			style="background-image: url(<?=$item['PREVIEW_PICTURE']['SRC']?>); display: <?=($showSlider ? 'none' : '')?>;">
    		</span>
    		<?
    		if ($item['SECOND_PICT'])
    		{
    			$bgImage = !empty($item['PREVIEW_PICTURE_SECOND']) ? $item['PREVIEW_PICTURE_SECOND']['SRC'] : $item['PREVIEW_PICTURE']['SRC'];
    			?>
    			<span class="product-item-image-alternative" id="<?=$itemIds['SECOND_PICT']?>"
    				style="background-image: url(<?=$bgImage?>); display: <?=($showSlider ? 'none' : '')?>;">
    			</span>

    совсем также не удалось сделать, пришлось костыльнуть :

    $bgImage = !empty($item['PREVIEW_PICTURE_SECOND']) ? $item['PREVIEW_PICTURE_SECOND']['SRC'] : $item['PREVIEW_PICTURE']['SRC'];
    
    ?>
    
    <? if (true == is_array($arElement["PREVIEW_PICTURE"])) { ?>
    	<div class="gallery-product__boximg"><a href="<?= $URL ?>"><img src="<?= $URL ?>" alt="" class="gallery-product__img"></a></div> 
    
    <? } else { ?>
    	<div class="gallery-product__boximg"><a href="<?= $bgImage ?>"><img src="<?= $bgImage ?>" alt="" class="gallery-product__img"></a></div> 
    <? } ?>

    Лучше делать как в .default, чтобы потом не костылить, кроме того в моем варианте в случае отсутствия картинки в анонсе, в превью разделов будет выводиться заглушка (несмотря на наличие картинки в "изображениях")

    • 0
  3. Александр
    2020-03-08T10:51:01Z2020-03-08T10:51:01Z

    默认情况下会显示一个标准存根。它位于组件的模板文件夹中,将其替换为您的图片就可以了,为什么要乱码。

    • 0

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    是否可以在 C++ 中继承类 <---> 结构?

    • 2 个回答
  • Marko Smith

    这种神经网络架构适合文本分类吗?

    • 1 个回答
  • Marko Smith

    为什么分配的工作方式不同?

    • 3 个回答
  • Marko Smith

    控制台中的光标坐标

    • 1 个回答
  • Marko Smith

    如何在 C++ 中删除类的实例?

    • 4 个回答
  • Marko Smith

    点是否属于线段的问题

    • 2 个回答
  • Marko Smith

    json结构错误

    • 1 个回答
  • Marko Smith

    ServiceWorker 中的“获取”事件

    • 1 个回答
  • Marko Smith

    c ++控制台应用程序exe文件[重复]

    • 1 个回答
  • Marko Smith

    按多列从sql表中选择

    • 1 个回答
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Suvitruf - Andrei Apanasik 什么是空? 2020-08-21 01:48:09 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5