如何在zencart产品页下方增加随机产品列表

Share on:

1.首先找到文件includes/templates/模板名/templates/tpl_product_info_display.php

找到代码<!–eof also purchased products module–>在下方加入


<span style=“font-size: medium;“><?php </span>
<span style=“font-size: medium;“>require($template->get_template_dir(‘tpl_modules_whats_new.php’,DIR_WS_TEMPLATE, $current_page_base,‘templates’). ‘/tpl_modules_whats_new.php’);</span>
<span style=“font-size: medium;“>?></span>


<span style="font-size: medium;">这里我们调用的是新产品的函数,所以<strong>zencart中产品页下方显示的是随机产品</strong>。</span>

<span style="font-size: medium;">2.然后找到includes/templates/模板名/common/tpl_columnar_display.php用下面的代码覆盖这个文件下的代码</span>

<pre><code class="php"> 
<!--?php /** * Common Template - tpl_columnar_display.php * * This file is used for generating tabular output where needed, based on the supplied array of table-cell contents. * * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: tpl_columnar_display.php 3157 2006-03-10 23:24:22Z drbyte $ */ ?-->
> 0 ) {
        $params = "";
        for($col=0;$col&lt;3;$col++) {  //这边的3是显示zencart产品页下方随机产品数,默认是一行,所以就是一行三列的显示模式如果改成4就是一行4列,不过没有测试过。
          $r_params = "";
          if (isset($list_box_contents[0][$col]['params'])) $r_params .= ' ' . (string)$list_box_contents[0][$col]['params'];
            if (isset($list_box_contents[0][$col]['text'])) {
                echo '' . $list_box_contents[0][$col]['text'] .  '' . "\n"; 
            }
        }
    ?&gt;
    

     0 ) {
         for($row=0;$row' . $list_box_contents[$row][$col]['text'] .  '' . "\n"; 
                 }
            }
?&gt;
&lt;div' .="" $r_params="" '=""&gt;&lt;sizeof($list_box_contents);$row++) {="" $params="" ;="" if="" (isset($list_box_contents[$row]['params']))="" .=" " $list_box_contents[$row]['params'];="" for($col="0;$col&lt;sizeof($list_box_contents[$row]);$col++)" $r_params="" (isset($list_box_contents[$row][$col]['params']))="" (string)$list_box_contents[$row][$col]['params'];="" (isset($list_box_contents[$row][$col]['text']))="" echo="" '&lt;div'="" '=""&gt;
 

<!--?php } } } ?-->