У меня торговые предложения разделены на 3 вкладки. Хочу вывести для 1 вкладки модели картинки свойств торговых предложений так чтобы они соответствовали двум другим, например если у меня цвет двери красный и наличники обычные чтобы в модели это учитывалось и выводилась картинка конкретно торгового предложения с учетом этих двух свойств ну и самой модели. Код sku.php
вот у них так сделано
Скрытый текст |
|---|
| Код |
|---|
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die(); ?>
<?php
use intec\core\helpers\Html;
/**
* @var array $arResult
* @var array $arVisual
*/
?>
<st yle>
.my-tab {
overflow: hidden;
background-color: #ffffff;
display: flex;
flex-wrap: wrap;
margin-top: 10px;
}
.my-tab button {
width: calc(33.33% - 10px);
background-color: #ddd;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
text-align: center;
margin: 5px;
}
.my-tab button.my-active {
background-color: #d03349;
color: white;
border: 2px solid #d03349;
}
.my-tabcontent {
display: none;
padding: 6px 12px;
border-top: none;
width: 100%;
}
@media screen and (max-width: 600px) {
.my-tab button {
width: 100%;
margin-top: 0px;
margin-bottom: 0px;
}
}
.my-offer-row {
display: flex;
flex-wrap: wrap;
margin: 0 -5px; /* убираем внешние отступы */
}
.my-offer-button {
width: 70px; /* 20% ширины с учетом отступов */
height: 70px;
margin: 5px;
overflow: hidden;
position: relative;
transition: 0.3s;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.my-offer-button img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
outline: none;
border: none;
overflow: hidden;
}
.my-offer-button .my-offer-title {
display: none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.8);
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: bold;
text-align: center;
}
.my-offer-button:hover .my-offer-title {
display: flex;
}
/* Стили для кнопок внутри вкладки "Модель" */
#my_tab_model .my-offer-button {
width: 100px; /* 100% ширины с учетом отступов */
height: 100%; /* Устанавливаем высоту кнопки в 100% */
}
</style>
<?php if ($arResult['SKU_PROPS_SHOW']) { ?>
<div class="my-tab">
<?php
$tabs = [
'my_tab_model' => 'Модель',
'my_tab_material_color' => 'Материал и цвет',
'my_tab_portal_design' => 'Оформление портала'
];
$firstTab = true;
?>
<?php foreach ($tabs as $tabId => $tabTitle) { ?>
<button class="my-tabbutton<?= $firstTab ? ' my-active' : '' ?>" oncl ick="openTab(event, '<?= $tabId ?>')"><?= $tabTitle ?></button>
<?php $firstTab = false; ?>
<?php } ?>
</div>
<?php foreach ($tabs as $tabId => $tabTitle) { ?>
<div id="<?= $tabId ?>" class="my-tabcontent" st yle="<?= $tabId !== 'my_tab_material_color' ? 'display:none;' : '' ?>">
<?php
foreach ($arResult['SKU_PROPS'] as $arProperty) {
if (($tabId === 'my_tab_model' && $arProperty['id'] === 439) ||
($tabId === 'my_tab_material_color' && in_array($arProperty['id'], [435, 437, 438])) ||
($tabId === 'my_tab_portal_design' && $arProperty['id'] === 436)) { ?>
<?= Html::beginTag('div', [
'class' => 'my-offer-property',
'data' => [
'role' => 'property',
'type' => $arProperty['type'],
'property' => $arProperty['code']
]
]) ?>
<div class="my-offer-property-title">
<?= $arProperty['name'] ?>
</div>
<div class="my-offer-row">
<?php foreach ($arProperty['values'] as $arValue) { ?>
<?= Html::beginTag('div', [
'class' => [
'my-offer-value',
'intec-cl-border-hover',
'my-offer-button'
],
'data' => [
'role' => 'property.value',
'value' => $arValue['id'],
'state' => 'hidden'
]
]) ?>
<img src="<?= $arValue['picture'] ?>" alt="<?= $arValue['name'] ?>">
<div class="my-offer-title"><?= $arValue['name'] ?></div>
<?= Html::endTag('div') ?>
<?php } ?>
</div>
<?= Html::endTag('div') ?>
<?php }
} ?>
</div>
<?php } ?>
<sc ript>
function openTab(evt, tabId) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("my-tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("my-tabbutton");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" my-active", "");
}
document.getElementById(tabId).style.display = "block";
evt.currentTarget.className += " my-active";
}
// Set the first tab as active on page load
document.querySelector('.my-tabbutton').click();
</sc ript>
<?php } ?>
|