2017-01-17 3 views
0

dl listを使用して大きな属性テーブルを2つの別々の列に分割したいと考えています。 Opencartバージョン2.2.0.0Opencartの2つの列で奇数/偶数で属性グループを分割

コードは(/view/theme/default/template/product/product.tplに)ある:

<?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 } ?> 

任意のアイデア? ありがとうございます。

答えて

1

配列を2に分割し、foreachを使用してそれらをループトラフすることができます。私はこれがあなたのために良い仕事します推測

How can i take an array, divide it by two and create two lists?

<?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 } ?> 

は、そのためのCSSのソリューションがあるかもしれませんが、あなたは、PHPでそれをタグ付け。

+0

ありがとうございました! – Aaviya

関連する問題