ECSHOPのSmartyに関する質問

WBOY
リリース: 2016-06-13 12:02:34
オリジナル
1016 人が閲覧しました

ECSHOP の Smarty の問題について

この投稿は u011850217 によって最終編集されました (2014-07-19 13:01:06)これは、ecshop ハンド机端末のインデックス モジュールの第 1 段階コード

<br>define('IN_ECS', true);<br>require(dirname(__FILE__) . '/includes/init. php');<br>$type = !empty($_GET['type']) ? $_GET['type'] : 'best';<br>if ($type != 'best' && $type != 'promote' && $type != 'hot' && $type != 'new')<br>{<br> $type = 'best';<br>}<br>$smarty->assign('type', $type);<br><br>if (empty($_GET['order_price ']))<br>{<br> $order_rule = 'ORDER BY shop_price ASC, g.last_update DESC';<br>}<br>else<br>{<br> $order_rule = 'ORDER BY shop_price DESC, g.last_update DESC';<br>}<br><br>if ($type == 'promote')<br>{<br> $goods = wap_get_promote_goods($order_rule);<br>}<br>else <br>{<br> $goods = wap_get_recommend_goods($type, $order_rule);<br>}<br><br>$num = count($goods);<br>if ($num > 0)<br>{<br> foreach ($goods as $key => $data)<br> {<br> $sort_array[$data['id']] = $key;<br> }<br> $page_num = '10';<br> $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;<br> $pages = ceil($num / $page_num);<br> if ($page  {<br> $page = 1;<br> }<br> if ($pages == 0)<br> {<br> $pages = 1;<br> }<br> if ($page > $pages)<br> {<br> $page = $pages;<br> }<br> $i = 1;<br> foreach ($sort_array as $goods_key)<br> {<br> if (($i > ($page_num * ( $page - 1 ))) && ($i <= ($page_num * $page)))<br /> {<br /> $price = empty($goods[$goods_key]['promote_price_org']) ? $goods[$goods_key]['shop_price'] : $goods[$goods_key]['promote_price'];<br /> //$wml_data .= "<a href='goods.php?id={}'&gt ;".encode_output($goods[$goods_key]['name'])."</a>[".encode_output($price)."]<br/>";<br> $goods_data[] = array('i' =>$i , 'price' => encode_output($price) , 'id' => $goods[$goods_key]['id'] , 'name' => encode_output( $goods[$goods_key]['name']),'thumb' =>$goods[$goods_key]['thumb']);//16:43 2013-07-16<br> }<br> $ i ;<br> }<br> $smarty->assign('goods_data', $goods_data);<br> $pagebar = get_wap_pager($num, $page_num, $page, 'goods_list.php?type='. $type.'&order_price='.(empty($order_price)?0:$order_price), 'page');<br> $smarty->assign('pagebar', $pagebar);<br>}<br><br>$smarty->assign('footer', get_footer());<br>$smarty->display('goods_list.html');<br><br><br><br><br>function wap_get_recommend_goods($type = '', $order_rule = '')<br>{<br> if (!in_array($type, array('best', 'new', 'hot')))<br> {<br> return array();<br> }<br><br> //取異なる推荐对应的商品<br> static $type_goods = array();<br> if (empty($type_goods[$ type]))<br> {<br> //初期化数据<br> $type_goods['best'] = array();<br> $type_goods['new'] = array();<br> $type_goods ['hot'] = array();<br> $data = read_static_cache('recommend_goods');<br> if ($data === false)<br> {<br> $sql = 'SELECT g.goods_id 、g.is_best、g.is_new、g.is_hot、g.is_promote、b.brand_name、g.sort_order ' .<br> ' FROM ' 。 $GLOBALS['ecs']->table('goods') 。 ' AS g ' .<br> ' LEFT JOIN ' 。 $GLOBALS['ecs']->table('brand') 。 ' AS b ON b.brand_id = g.brand_id ' .<br> ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.is_best = 1 OR g.is_new =1 OR g .is_hot = 1)'.<br> ' ORDER BY g.sort_order, g.last_update DESC';<br> $goods_res = $GLOBALS['db']->getAll($sql);<br> //定义推荐、最新、熱门、促進销商品<br> $goods_data['best'] = array();<br>$goods_data['new'] = array();<br> $goods_data['hot'] = array();<br> $goods_data['brand'] = array();<br> if (!empty( $goods_res))<br> {<br> foreach($goods_res as $data)<br> {<br> if ($data['is_best'] == 1)<br> {<br> $goods_data[' best'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);<br> }<br> if ($data[' is_new'] == 1)<br> {<br> $goods_data['new'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data[' sort_order']);<br> }<br> if ($data['is_hot'] == 1)<br> {<br> $goods_data['hot'][] = array('goods_id' => $data['goods_id'],'sort_order' => $data['sort_order']);<br> }<br> if ($data['brand_name'] != '')<br> {<br> $goods_data['brand'][$data['goods_id']] = $data['brand_name'];<br> }<br> }<br> }<br> write_static_cache('recommend_goods', $goods_data) ;<div class="clear"></div>
ログイン後にコピー
関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート