L
L
lord amotar2016-02-24 14:48:32
1C-Bitrix
lord amotar, 2016-02-24 14:48:32

How to display the title correctly?

good day!
there is an online store selling tires
tires have properties ( 195/65R14 width/heightRdiameter )
tires are divided into several groups light truck, etc.
correct display for passenger car tire 195/65R14
correct display for truck tire 10.00
R20 in the properties of a truck tire there is no concept of tire height the
question is how to make the properties displayed on both truck and passenger tires
correct display for a passenger tire 195/65R14
correct display for a truck tire 10.00 R20 I

am attaching the display template code

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<div class="catalogTabsContent">
  <div class="item" style="display:block">
        <div class="catalogLotsList">
    
    <?if (count($arResult["ITEMS"])==0):?>
      <?if (!empty($_REQUEST['select']) || !empty($_REQUEST['car'])):?>
      <div class="alert alert-block"><b>По Вашему запросу ничего не найдено.</b> <a href="<?=$APPLICATION->GetCurDir()?>">Отменить фильтр?</a></div>
      <?else:?>
      <div class="alert alert-block"><b>Данный раздел не содержит элементов.</b> </div>
      <?endif?>
    <?endif?>
    
    
    <?
    $num = 0;
    CModule::IncludeModule("iblock");
    global $catalogFilter;
    $filterNum = array_merge(array('IBLOCK_ID'=>$arParams["IBLOCK_ID"],'ACTIVE'=>"Y"),$catalogFilter);
    $res_total = CIBlockElement::GetList($sort,$filterNum, false, false, array('ID'));
    $total = $res_total->SelectedRowsCount();

    ?>
    <?foreach($arResult["ITEMS"] as $cell=>$arElement):?>
    <?
    $this->AddEditAction($arElement['ID'], $arElement['EDIT_LINK'], CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_EDIT"));
    $this->AddDeleteAction($arElement['ID'], $arElement['DELETE_LINK'], CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BCS_ELEMENT_DELETE_CONFIRM')));
    
    if(!is_array($arElement["PREVIEW_PICTURE"]) && is_array($arElement["DETAIL_PICTURE"])) $arElement["PREVIEW_PICTURE"] = $arElement["DETAIL_PICTURE"];
    if (is_array($arElement["PREVIEW_PICTURE"])) $preview = CFile::ResizeImageGet($arElement["PREVIEW_PICTURE"]['ID'], array('width'=>138, 'height'=>200), BX_RESIZE_IMAGE_PROPORTIONAL, true);         
    $num++;
    
    if ($arParams["IBLOCK_ID"]==4){
      $nameArr = array();
      $nameArr[]='Шины';
      if (!empty($arElement['PROPERTIES']['width']['VALUE']) && !empty($arElement['PROPERTIES']['height']['VALUE']) && !empty($arElement['PROPERTIES']['diametr']['VALUE'])) $nameArr[]=$arElement['PROPERTIES']['width']['VALUE'].'/'.$arElement['PROPERTIES']['height']['VALUE'].'R'.$arElement['PROPERTIES']['diametr']['VALUE'].' '.$arElement['PROPERTIES']['iNag']['VALUE'].' '.$arElement['PROPERTIES']['iSkor']['VALUE'];
      if (!empty($arElement['PROPERTIES']['model']['VALUE'])) $nameArr[]=$arElement['PROPERTIES']['model']['VALUE'].',';
      if (!empty($arElement['PROPERTIES']['brand']['VALUE'])) $nameArr[]=dev::getEl($arElement['PROPERTIES']['brand']['VALUE'],'NAME');

      $arElement["NAME"] = implode(" ",$nameArr);
    }elseif ($arParams["IBLOCK_ID"]==5){
      $nameArr = array();
      $nameArr[]='Диски';
      if (!empty($arElement['PROPERTIES']['brand']['VALUE'])) $nameArr[]=dev::getEl($arElement['PROPERTIES']['brand']['VALUE'],'NAME');
      if (!empty($arElement['PROPERTIES']['model']['VALUE'])) $nameArr[]=$arElement['PROPERTIES']['model']['VALUE'];
      if (!empty($arElement['PROPERTIES']['width']['VALUE']) && !empty($arElement['PROPERTIES']['diametr']['VALUE'])) $nameArr[]=$arElement['PROPERTIES']['width']['VALUE'].'*'.$arElement['PROPERTIES']['diametr']['VALUE'].',';
      if (!empty($arElement['PROPERTIES']['diametr_otv']['VALUE'])) $nameArr[]=$arElement['PROPERTIES']['diametr_otv']['VALUE'].' (PCD)';
      $arElement["NAME"] = implode(" ",$nameArr);
    }
    ?>
<!--
    <div class="lotItem" id="<?=$this->GetEditAreaId($arElement['ID']);?>">
      <?if($arElement['PROPERTIES']['promo']['VALUE_ENUM_ID']>0):?><div class="action"></div><?endif?> -->




<div class="lotItem" id="<?=$this->GetEditAreaId($arElement['ID']);?>">
      <?if($arElement['PROPERTIES']['promo']['VALUE_ENUM_ID']>0):?>
      <div class="action"></div>
      <?elseif($arElement['PROPERTIES']['is_new']['VALUE_ENUM_ID']>0):?>
      <div class="new"></div>
      <?elseif($arElement['PROPERTIES']['is_hit']['VALUE_ENUM_ID']>0):?>
      <div class="hit"></div>
      <?endif?>



<a href="<?=$arElement["DETAIL_PAGE_URL"]?>" class="image">
        <center>
          <?if ($preview):?>
            <img src="<?=$preview['src']?>" title="<?=$arElement["NAME"]?>" alt="<?=$arElement["NAME"]?>">
          <?else:?>
            <?
            if ($arParams["IBLOCK_ID"]==4) $nophoto = 'no-tire.jpg';
            elseif ($arParams["IBLOCK_ID"]==5) $nophoto = 'no-disk.jpg';
            elseif ($arParams["IBLOCK_ID"]==10) $nophoto = 'no-akk.jpg';
            ?>
            <img src="/pic/<?=$nophoto?>" title="<?=$arElement["NAME"]?>" alt="<?=$arElement["NAME"]?>">
          <?endif?>
        </center>
      </a>
      <div class="discr">
        <a href="<?=$arElement["DETAIL_PAGE_URL"]?>"target="_blank" class="title"><?=$arElement["NAME"]?></a>
        <div class="text">
          <?=TruncateText(strip_tags($arElement["PREVIEW_TEXT"]),150)?> 
        </div>
        <form action="<?=POST_FORM_ACTION_URI?>" method="post" enctype="multipart/form-data">
        <?if($arElement["CAN_BUY"]):?>
        <table class="orderTable">
          <?if($arParams["USE_PRODUCT_QUANTITY"]):?>
          <tr>
            <td>Кол-во:</td>
            <td><input type="text" name="<?echo $arParams["PRODUCT_QUANTITY_VARIABLE"]?>" value="4" id="item_q_<?=$arElement["ID"]?>" class="numberField"></td>
          </tr>
          <?endif?>
          <tr>
            <td>Цена за 1 шт.:</td>
            <td>
              <?$price=10000000;$print_price=0;$priceName='';?>
              <?foreach($arElement["PRICES"] as $code=>$arPrice){
                if($arPrice["CAN_ACCESS"]=="Y"){
                  if ($price==10000000 || ($arPrice["DISCOUNT_VALUE"]>0 && $price>0 && $price>$arPrice["DISCOUNT_VALUE"])){
                    $price = $arPrice["DISCOUNT_VALUE"];
                    $print_price = $arPrice["PRINT_DISCOUNT_VALUE"];
                    $priceName = $arResult["PRICES"][$code]["TITLE"];
                  }
                  
                }
              }
              ?>
              <?if ($price>0):?><div class="price" title="<?=$priceName?>"><?=$print_price?></div><?endif?>
            </td>
          </tr>
        </table>
        <?endif?>
        <div class="clear"></div>
        <div class="sep_line"></div>
        <?if ($arElement['PROPERTIES']['brand']['VALUE'] && $brand_pic = dev::getEl($arElement['PROPERTIES']['brand']['VALUE'],'PREVIEW_PICTURE')):?>
          <div class="lotBrandBlock"><?if (is_numeric($brand_pic)):?><img src="<?=CFile::GetPath($brand_pic)?>" alt=""><?endif?></div>
        <?endif?>
        <?if ($arElement['PROPERTIES']['sezon']['VALUE'] && $sezon = dev::getEl($arElement['PROPERTIES']['sezon']['VALUE'])):?>
          <div class="lotWetherBlock"><?if (!empty($sezon['PREVIEW_PICTURE'])):?><img src="<?=CFile::GetPath($sezon['PREVIEW_PICTURE'])?>" alt=""><?endif?><?=$sezon['NAME']?></div>
          <!-- <div class="lotWetherBlock"><?if (!empty($sezon['PREVIEW_PICTURE'])):?><img src="<?=CFile::GetPath($sezon['PREVIEW_PICTURE'])?>" alt=""><?endif?><?=$sezon['NAME']?></div> -->
        <?endif?>
        
        
        
        <?if($arElement["CAN_BUY"]):?>
          <input type="hidden" name="<?echo $arParams["ACTION_VARIABLE"]?>" value="BUY">
          <input type="hidden" name="<?echo $arParams["PRODUCT_ID_VARIABLE"]?>" value="<?echo $arElement["ID"]?>">
          <input type="submit" name="<?echo $arParams["ACTION_VARIABLE"]."BUY"?>" value="<?echo GetMessage("CATALOG_BUY")?>" style="display:none;">
          <input type="submit" class = "addToOrderB" name="<?echo $arParams["ACTION_VARIABLE"]."ADD2BASKET"?>" value="<?echo GetMessage("CATALOG_ADD")?>" style="display:none;">
          <a href="javascript:void(0);" class="blueBtn addToOrderBtn" data-q="item_q_<?=$arElement["ID"]?>" data-id="<?=$arElement["ID"]?>" data-title="<?=$arElement["NAME"]?>" data-img="<?=$preview['src']?>">Добавить в заказ</a>
        <?endif?>
        </form>
        <div class="clear"></div>
      </div>
      <div class="clear"></div>
    </div>
    
    <?endforeach; // foreach($arResult["ITEMS"] as $arElement):?>
    
    </div>
    <?if ($total>0 && count($arResult["ITEMS"])>0):?>
      <div class="searchResult">
        <?
        $onpage = $arParams["PAGE_ELEMENT_COUNT"];
        if (isset($_REQUEST['PAGEN_1']) && is_numeric($_REQUEST['PAGEN_1'])) $curpage = intval($_REQUEST['PAGEN_1']); else $curpage = 1;
        $from = ($curpage-1)*$onpage+1;
        $to = $from + $num - 1;
        ?>
        Показаны c <?=$from?> по <?=$to?> из <?=$total?> моделей
      </div>
    <?endif?>
    
    <?if($arParams["DISPLAY_BOTTOM_PAGER"]):?>
      <?=$arResult["NAV_STRING"]?>
    <?endif;?>
  </div>
  
</div>

<script type="text/javascript">
$(function(){
  $('a.addToOrderBtn').on('click',function(e){
    e.preventDefault();
    //$(this).prev().trigger('click');
    addToCart(this,$(this).data('q'));
  });
});
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question