码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-09-16 20:26:00      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   ar   for   div   art   

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));

 

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

标签:des   style   blog   color   io   ar   for   div   art   

原文地址:http://www.cnblogs.com/temps/p/3975663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!