meditation Posted May 21, 2010 Share Posted May 21, 2010 我的版本1.3,我想让主页FEATURED PRODUCTS里的产品每次刷新都能够随机出现,曾经在那里见过解决方法,但是现在找不到了,不知道有谁知道怎么作吗?谢谢先 Link to comment Share on other sites More sharing options...
SHEINLINE Posted December 2, 2010 Share Posted December 2, 2010 也在寻找这个答案。。。知道的,跟下贴,谢了!!! Link to comment Share on other sites More sharing options...
21846657 Posted December 2, 2010 Share Posted December 2, 2010 下面是我1.4a3的mod。备份后在modules/homefeatured/homefeatured.php里找到: $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); 在其下面加入: if ($products != false ) { shuffle($products); array_splice($products, ($nb ? $nb : 8)); } 就像下面这样: $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); if ($products != false ) { shuffle($products); array_splice($products, ($nb ? $nb : 8)); } Link to comment Share on other sites More sharing options...
SHEINLINE Posted December 2, 2010 Share Posted December 2, 2010 我的版本是 Version 1.3.0.2。按照 版主 的方法修改,可以正常实现这种功能。谢谢!-----------------------------------------------------------------if ($products != false ) { shuffle($products); array_splice($products, ($nb ? $nb : 8));} ------------------------------------------------------------这段代码能帮忙解释下???两个函数是什么意思?($nb ? $nb : 8) ,中的 '8‘ 是什么意思?? Link to comment Share on other sites More sharing options...
SHEINLINE Posted December 2, 2010 Share Posted December 2, 2010 http://www.prestashop.com/forums/viewthread/25785/third_party_modules/featured_products_module_help_dot_ Link to comment Share on other sites More sharing options...
21846657 Posted December 2, 2010 Share Posted December 2, 2010 -----------------------------------------------------------------if ($products != false ) { shuffle($products); array_splice($products, ($nb ? $nb : 8));} ------------------------------------------------------------这段代码能帮忙解释下???两个函数是什么意思?($nb ? $nb : 8) ,中的 '8‘ 是什么意思?? 先判断$products里有没有产品(有没有产品在Home分类下);如果有,就将$products里面的产品随机排序 (shuffle)。接下来,如果在homefeatured模块里设置了显示多少个产品($nb),那么,就按照设置的数量来显示这些产品 (array_splice);如果没有设置,就默认按照8个产品(如果够8个的话)来显示。我的homefeatured模块是一行4个,显示两行,所以我设置为8个。另外,如果已勾选Home分类的产品比较多的话,也可以将 $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); 修改为: $products = $category->getProducts(intval($params['cookie']->id_lang), 1, 100); 最后,像下面这样: $products = $category->getProducts(intval($params['cookie']->id_lang), 1, 100); if ($products != false ) { shuffle($products); array_splice($products, ($nb ? $nb : 8)); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now