<?php
|
|
/**
|
列出所有分类及品牌
|
* ============================================================================
|
* *
|
|
* ----------------------------------------------------------------------------
|
|
* ============================================================================
|
|
* $Id: catalog.php 17217 2011-01-19 06:29:08Z $
|
*/
|
|
define('IN_ECS', true);
|
|
require(dirname(__FILE__) . '/includes/init.php');
|
|
if ((DEBUG_MODE & 2) != 2)
|
{
|
$smarty->caching = true;
|
}
|
|
if (!$smarty->is_cached('catalog.dwt'))
|
{
|
/* 取出所有分类 */
|
$cat_list = cat_list(0, 0, false);
|
foreach ($cat_list AS $key=>$val)
|
{
|
if ($val['is_show'] == 0)
|
{
|
unset($cat_list[$key]);
|
}
|
}
|
|
|
assign_template();
|
assign_dynamic('catalog');
|
$position = assign_ur_here(0, $_LANG['catalog']);
|
$smarty->assign('page_title', $position['title']); // 页面标题
|
$smarty->assign('ur_here', $position['ur_here']); // 当前位置
|
|
$smarty->assign('helps', get_shop_help()); // 网店帮助
|
$smarty->assign('cat_list', $cat_list); // 分类列表
|
$smarty->assign('categories', get_categories_tree()); // 分类树
|
$smarty->assign('brand_list', get_brands()); // 所以品牌赋值
|
$smarty->assign('promotion_info', get_promotion_info());
|
}
|
|
$smarty->display('catalog.dwt');
|
|
/**
|
* 计算指定分类的商品数量
|
*
|
* @access public
|
* @param integer $cat_id
|
*
|
* @return void
|
*/
|
function calculate_goods_num($cat_list, $cat_id)
|
{
|
$goods_num = 0;
|
|
foreach ($cat_list AS $cat)
|
{
|
if ($cat['parent_id'] == $cat_id && !empty($cat['goods_num']))
|
{
|
$goods_num += $cat['goods_num'];
|
}
|
}
|
|
return $goods_num;
|
}
|
|
/*分类调用id广告*/
|
function get_advlist( $position, $num )
|
{
|
$arr = array( );
|
$sql = "select ap.ad_width,ap.ad_height,ad.ad_id,ad.ad_name,ad.ad_code,ad.ad_link,ad.ad_id from ".$GLOBALS['ecs']->table( "ecsmart_ad_position" )." as ap left join ".$GLOBALS['ecs']->table( "ecsmart_ad" )." as ad on ad.position_id = ap.position_id where ap.position_name='".$position.( "' and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1 limit ".$num );
|
$res = $GLOBALS['db']->getAll( $sql );
|
foreach ( $res as $idx => $row )
|
{
|
$arr[$row['ad_id']]['name'] = $row['ad_name'];
|
$arr[$row['ad_id']]['url'] = "affiche.php?ad_id=".$row['ad_id']."&uri=".$row['ad_link'];
|
$arr[$row['ad_id']]['image'] = "data/afficheimg/".$row['ad_code'];
|
$arr[$row['ad_id']]['content'] = "<a href='".$arr[$row['ad_id']]['url']."' target='_blank'><img src='data/afficheimg/".$row['ad_code']."' width='".$row['ad_width']."' height='".$row['ad_height']."' /></a>";
|
$arr[$row['ad_id']]['ad_code'] = $row['ad_code'];
|
}
|
return $arr;
|
}
|
?>
|