名称: products_section_data($page=1, $pagesize=10)
功能: 读取商品版块列表(按顶级分类分组提取下面TOP-N商品,用于商品版块展示,每个顶级分类为一个版块),一般用于商城类网站首页分版块展示商品,或新闻博客类网站分版块
模板代码示例:
{ephp}$_section_data = EsiteApp::app()->products_section_data(1, 20);{/ephp} {if($_section_data)}{loop $_section_data $k0 $v0} {ephp}$n = isset($n)?$n+1:1;{/ephp} <div class="col-md-12 sale-product"> <h2>#{$n} {$v0['cat_name']}</h2> <div class="bxslider-wrapper"> {if($v0['products'])} <ul class="bxslider" data-slides-phone="1" data-slides-tablet="2" data-slides-desktop="5" data-slide-margin="15"> {loop $v0['products'] $k1 $v1} <li> <div class="product-item"> <div class="pi-img-wrapper"> <img src="{$v1['image'][0]}" class="img-responsive" alt="{$v1['title']}"> <div> <a href="{$v1['image'][0]}" class="btn btn-default fancybox-button">放大</a> <a href="#product-pop-up" class="btn btn-default fancybox-fast-view" onclick="apps.product_pop_up(this)" product-data='{ephp}echo json_encode($v1);{/ephp}'>详情</a> </div> </div> <h3><a href="{$v1['product_url']}">{$v1['title']}</a></h3> <div class="pi-price">¥{$v1['price']}</div> <a href="javascript:;" class="btn btn-default add2cart" onclick="apps['cart-add']({$v1['id']},1);">加入购物车</a> <div class="sticker sticker-sale"></div> </div> </li> {/loop} </ul> {/if} </div> </div> {/loop}{/if}数据格式打印:
Array ( [1] => Array ( [cat_id] => 1 [category] => top_menu [parent_id] => 0 [unique_id] => 女士 [cat_name] => 女士 [title] => 女士服装包鞋帽 [keywords] => 女士,女装,女鞋,女包,女帽 [description] => [content] => [sort] => 1 [category_url] => /女士/p1-products.html [children] => Array ( [2] => Array ( [cat_id] => 2 [category] => top_menu [parent_id] => 1 [unique_id] => 女装 [cat_name] => 女装 [title] => 女装 [keywords] => 女装 [description] => 女装 [content] => [sort] => 0 [category_url] => /女装/p1-products.html [children] => Array ( [13] => Array ( [cat_id] => 13 [category] => top_menu [parent_id] => 2 [unique_id] => 女士T恤 [cat_name] => 女士T恤 [title] => 女士T恤 [keywords] => 女士T恤 [description] => 女士T恤 [content] => [sort] => 3 [category_url] => /女士T恤/p1-products.html ) ) ) ) [products] => Array ( [0] => Array ( [id] => 75 [cat_id] => 17 [filename] => [name] => 女装2018夏季新款高腰及膝蕾丝半身裙伞裙8200015 [price] => 400 [weight] => 0.18 [sn] => [title] => 女装2018夏季新款高腰及膝蕾丝半身裙伞裙8200015 [keywords] => 黑色 S M L [description] => 女装2018夏季新款高腰及膝蕾丝半身裙伞裙8200015 [content] => ... [image] => Array ( [0] => /esite_static/upload/image/day_180523/25bf64f7d715d00c6cc31a671ba408b7.jpg [1] => /esite_static/upload/image/day_180523/d34bdaac33b424fdce0bdbe508ca1776.jpg ) [edit_time] => 1532770948 [sort] => 0 [ext1] => [ext2] => [ext3] => [ext4] => [ext5] => [ext6] => [ext7] => [ext8] => [ext9] => [ext10] => [ext11] => [ext12] => [ext13] => [ext14] => [ext15] => [product_url] => /75-product.html [category_url] => /p1-products.html ) ) ) [29] => Array ( [cat_id] => 29 [category] => top_menu [parent_id] => 0 [unique_id] => 男士 [cat_name] => 男士 [title] => 男士 [keywords] => 男士 [description] => [content] => [sort] => 3 [category_url] => /男士/p1-products.html [children] => Array ( [30] => Array ( [cat_id] => 30 [category] => top_menu [parent_id] => 29 [unique_id] => 男士皮衣 [cat_name] => 皮衣 [title] => 皮衣 [keywords] => 皮衣 [description] => [content] => [sort] => 3 [category_url] => /男士皮衣/p1-products.html ) ) [products] => Array ( [0] => Array ( [id] => 225 [cat_id] => 40 [filename] => [name] => 男包2018春季新款时尚穿孔LOGO男包可调节肩带双肩包AB10067 [price] => 700 [weight] => 0.18 [sn] => [title] => 男包2018春季新款时尚穿孔LOGO男包可调节肩带双肩包AB10067 [keywords] => 黑 2 [description] => 男包2018春季新款时尚穿孔LOGO男包可调节肩带双肩包AB10067 [content] => ... [image] => Array ( [0] => /esite_static/upload/image/day_180523/81086d7a0d895a4c976e370b49d3e344.jpg [1] => /esite_static/upload/image/day_180523/94b0f1597b6a7f2eb9034be8f517924b.jpg ) [edit_time] => 1527080368 [sort] => 0 [ext1] => [ext2] => [ext3] => [ext4] => [ext5] => [ext6] => [ext7] => [ext8] => [ext9] => [ext10] => [ext11] => [ext12] => [ext13] => [ext14] => [ext15] => [product_url] => /225-product.html [category_url] => /p1-products.html ) ) ) )模板示例截图: