2016-08-24 63 views
1

我使用opencart 1.5.6.4,journal2主題,並在產品頁面上創建了一個自定義相關項目。只有某些產品我沒有任何相關項目,我想禁用它的顯示。顯示:無相關項目時無。 opencart 1.5.6.4

Screendump結果:

Screendump of result

會有人對如何做到這一點建議嗎?

我的代碼,XML vqmod:

<modification> 
    <id>Related Products Custom tab </id> 
    <version>1.2</version> 
    <vqmver>2.1.5</vqmver> 
    <author>13Pixels</author> 
    <file name="catalog/view/theme/journal2/template/product/product.tpl"> 
     <operation> 
      <search position="after"><![CDATA[<div class="related-custom-spot">]]> 
      </search> 
     <add><![CDATA[ 
<div class="related-custom" style="background-color: rgb(244, 244, 244);"> 
    <?php if ($heading_title): ?> 
    <div class="secondary-title" style="background-color: rgb(169, 184, 192); margin: 0px;"><?php echo $tab_related; ?></div> 
    <?php endif; ?> 
    <div class="related-custom-pictures"> 
      <?php foreach ($products as $product) { ?> 
       <?php if ($product['thumb']) { ?> 
        <a href="<?php echo $product['href']; ?>"> 
          <img style="border-width: 5px; border-style: solid; border-color: rgb(244, 244, 244);" width="50px" height="50px" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /> 
         </a> 

        <?php } ?>   
       <?php } ?> 
      </div> 
    </div> 
     ]]></add> 
     </operation> 
    </file> 
</modification> 

回答

0

您可以添加以下條件,顯示相關項目

<?php if ($products) { ?> 
//your code to display related items 
<?php } ?> 

希望這有助於在你面前!

+0

完美!謝了哥們! – Youri

+0

您有關於如何對圖像進行排序的建議嗎?例如;產品表中的排序順序表?那麼這將是完美的,請參閱:https://www.rijstextiles.com/net-stof-stretch-mesh/mesh-stof-stretch-zwart.html – Youri

+0

<?php foreach($ sorts as $ sorts){?> – Youri