ECSHOP获得指定商品分类下所有的商品关联文章

/**
 * 获得指定分类下所有商品的关联文章
 * sun04zh3-20130321
 * @access  public
 * @param   integer     $cat_id
 * @return  array
 */
function get_category_linked_articles($cat_id)
{
    $sql = ‘SELECT a.article_id, a.title, a.file_url, a.open_type, a.add_time ‘ .
            ‘FROM ‘ . $GLOBALS[‘ecs‘]->table(‘goods_article‘) . ‘ AS ga, ‘ .
                $GLOBALS[‘ecs‘]->table(‘article‘) . ‘ AS a, ‘ .
                $GLOBALS[‘ecs‘]->table(‘goods‘).‘ AS g ‘.
            "WHERE ga.article_id = a.article_id AND ".get_children($cat_id)." AND a.is_open = 1 and ga.goods_id = g.goods_id " .
            ‘ORDER BY a.add_time DESC‘;
    $res = $GLOBALS[‘db‘]->query($sql);

    $arr = array();
    while ($row = $GLOBALS[‘db‘]->fetchRow($res))
    {
        $row[‘url‘]         = $row[‘open_type‘] != 1 ?
            build_uri(‘article‘, array(‘aid‘=>$row[‘article_id‘]), $row[‘title‘]) : trim($row[‘file_url‘]);
        $row[‘add_time‘]    = local_date($GLOBALS[‘_CFG‘][‘date_format‘], $row[‘add_time‘]);
        $row[‘short_title‘] = $GLOBALS[‘_CFG‘][‘article_title_length‘] > 0 ?
            sub_str($row[‘title‘], $GLOBALS[‘_CFG‘][‘article_title_length‘]) : $row[‘title‘];

        $arr[] = $row;
    }

    return $arr;
}

category.dwt模版页调用:

<!--{foreach from=$article_list_jnc item=jnclist}-->
            <li><a href="{$jnclist.url}"  title="{$jnclist.title}">{$jnclist.title}</a></li>
            <!--{/foreach}-->

category.php对应程序页调用:

$smarty->assign(‘article_list‘,     get_category_linked_articles(8));
时间: 2024-08-25 20:50:46

ECSHOP获得指定商品分类下所有的商品关联文章的相关文章

ecshop调用指定商品分类下的商品

在系统目录文件找到includes/lib_goods.php  这个文件打开在此页最底部加入以下函数代码: /** * 首页获取指定分类产品 * * @access public * @param string $cat_id53_best_goods * @param array $cat_id53_best_goods * @return array */ function get_cat_id_goods_list($cat_id = '', $num = '') { $sql = 'S

ecshop首页调用指定商品分类下的商品品牌列表

转之--http://www.16css.com/ecshop/735.html 通过二次开发可以实现ECSHOP首页调用指定分类下的品牌列表. 第一步: 打开根目录下的index.php 在最后面 ?> 前面加入以下代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /** * 获得某个分类下的品牌 列表 * * @access  public * @param   int     $cat * @return 

ectouch手机商城首页调用指定分类下的商品

ECTouch是国内市面上唯一开源的ECSHOP移动商城系统,为广大电商以最低的成本快速搭建移动商城.最近最一商城实例,手机版首页需要调用指定分类下的商品,ECtouch商城默认好像没有此调用方式,只能自己动手添加了. 方法如下: 1.打开mobile\include\apps\default\model\IndexModel.class.php 在最下面 } 之前添加以下代码 /**      * 获得指定分类下的商品      */      function assign_cat_good

ecshop首页调用指定分类下面的精品商品

1.首先在index.php页面加上这段代码: function index_get_cat_id_goods_best_list($cat_id, $num){    $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' .                "promote_start_date, promote_end_date,

ecshop 首页调用指定分类下的销售排行

/*首页调用指定分类下的销售排行*/ function get_cats_top10($cat = '') { $sql = 'SELECT cat_id, cat_name ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$cat' ORDER BY sort_order ASC, cat_id ASC LIMIT 3"; $res = $GLOBALS['db']->getAl

ECSHOP商品分类列表显示一个空商品错位修改

在我们制作ecshop之时,有时候会发现商品列表或者其他商品页最后会多出一个商品其实解决只要在商品循环列表中加一个判断就可以,像这样:  {if $goods.url}这里是商品代码{/if}  因为我发现空商品的url是空的,当然,你也可以用其他的key来判断.其他页:如<!-- {if $best_goods} --><!-- {/if} -->等等,如果有精品商品 显示什么什么.所有在做模板 在商品是否为空判断是有必要的.

oracle 统计指定条件下所有表的行数

今天 需要统计下指定用户下的所有表的行数,于是采用了oracle 内置视图: select table_name,num_rows  from dba_tables where owner = 'USERNAME';  或 select table_name,num_rows from user_all_tables ; 可是统计结果发现,有的表的统计数量和实际数量有差异,因此,直接自己写了个统计指定条件下表的记录的sql: --创建一个表用于存储计算结果 create table t_temp

Scala 获取指定目录下的所有文件名(不包括目录名)

最近在学习Scala,想要获取指定目录下的所有文件名,但是Scala  中有没有相应的库函数,由于本人是新手,所以弄了半天,好不容易才将网上的一段Scala 递归获取指定目录下所有目录的代码改成获取文件名,特在此备忘,也希望高手指点. 下面是一段递归获取目录名称的代码: def subdirs(dir: File): Iterator[File] = { val children = dir.listFiles.filter(_.isDirectory) children.toIterator

python之查询指定目录下的最新文件

使用os模块查询指定目录下的最新文件 1 import os 2 3 # 输入目录路径,输出最新文件完整路径 4 def find_new_file(dir): 5 '''查找目录下最新的文件''' 6 file_lists = os.listdir(dir) 7 file_lists.sort(key=lambda fn: os.path.getmtime(dir + "\\" + fn) 8 if not os.path.isdir(dir + "\\" + f