Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Opencart中按奇数/偶数在两列中拆分属性组_Php_Opencart - Fatal编程技术网

Php 在Opencart中按奇数/偶数在两列中拆分属性组

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="

我想用dl list将大属性表拆分为两个单独的列。Opencart版本2.2.0.0

现在的代码是(在/view/theme/default/template/product/product.tpl中):


有什么想法吗?
提前感谢。

您可以将阵列拆分为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 } ?>