Php 在Opencart中按奇数/偶数在两列中拆分属性组
我想用dl list将大属性表拆分为两个单独的列。Opencart版本2.2.0.0 现在的代码是(在/view/theme/default/template/product/product.tpl中):Php 在Opencart中按奇数/偶数在两列中拆分属性组,php,opencart,Php,Opencart,我想用dl list将大属性表拆分为两个单独的列。Opencart版本2.2.0.0 现在的代码是(在/view/theme/default/template/product/product.tpl中): 有什么想法吗? 提前感谢。您可以将阵列拆分为2个阵列,并使用foreach对其进行循环 可能也有css解决方案,但你用php标记了它,所以我想这对你来说会更好 <?php if ($attribute_groups) { ?> <div class="
有什么想法吗?
提前感谢。您可以将阵列拆分为2个阵列,并使用foreach对其进行循环
可能也有css解决方案,但你用php标记了它,所以我想这对你来说会更好
<?php if ($attribute_groups) { ?>
<div class="tab-pane tab-content <?php if ($is_active) { echo 'active'; $is_active = false; } ;?>" id="tab-specification">
<dl>
<?php foreach ($attribute_groups as $attribute_group) { ?>
<p><strong><?php echo $attribute_group['name']; ?></strong></p>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<dt><?php echo $attribute['name']; ?></dt>
<dd><?php echo $attribute['text']; ?></dd>
<?php } ?>
<?php } ?>
</dl>
</div>
<?php } ?>
<?php if ($attribute_groups) {
$firsthalf = array_slice($attribute_groups, 0, $len / 2);
$secondhalf = array_slice($attribute_groups, $len / 2);
?>
<div class="tab-pane tab-content <?php if ($is_active) { echo 'active'; $is_active = false; } ;?>" id="tab-specification">
<dl>
<?php foreach ($firsthalf as $attribute_group) { ?>
<p><strong><?php echo $attribute_group['name']; ?></strong></p>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<dt><?php echo $attribute['name']; ?></dt>
<dd><?php echo $attribute['text']; ?></dd>
<?php } ?>
<?php } ?>
</dl>
<dl>
<?php foreach ($secondhalf as $attribute_group) { ?>
<p><strong><?php echo $attribute_group['name']; ?></strong></p>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<dt><?php echo $attribute['name']; ?></dt>
<dd><?php echo $attribute['text']; ?></dd>
<?php } ?>
<?php } ?>
</dl>
</div>
<?php } ?>